Skip to content
PlatformMarkdown

Signing keys

The keys that sign your realm's tokens, published ahead of use and rotated or revoked without any app refusing a token.

AvailableAPIRFC 7517, RFC 7518, RFC 7638

Every token your realm issues is signed, so an app or API can check that the realm made it and nobody changed it. Each realm has its own signing keys. No API returns them, to you or anyone else; apps and APIs check signatures against the public halves, which the realm publishes.

You rotate the keys whenever you choose: a new key is published before it signs anything, so no app ever meets a token signed by a key it doesn’t have yet. When you no longer trust a key, you revoke it, and nothing it signed verifies again. Keys never rotate on their own.

  • Privilege: MODIFY on the realm’s keySettings, which RealmOwner gives. Listing, rotating and revoking all need it.
  • Where: the API. Keys in the dashboard are planned.
  • First: your session in $CVYUH_SESSION (Call the API).

A realm is born with one signing key for each of three algorithms. Each signs different tokens:

AlgorithmWhat it signs
ES256Access tokens, always. Status lists, security events and the bootstrap assertions you mint for an agent. ID tokens and signed userinfo answers for clients that ask for it, and ID tokens by default for a fapi2 client
RS256ID tokens by default. Signed introspection answers by default, except for a fapi2 client. Identity assertions, chaining grants and transaction tokens
PS256ID tokens and signed userinfo answers for clients that ask for it, such as FAPI 2.0 clients, once you add PS256 to keySettings.algorithm.oauth2.idToken

A client picks its ID-token algorithm with idTokenSignedResponseAlg, its userinfo algorithm with userinfoSignedResponseAlg, and its signed introspection algorithm with introspectionSignedResponseAlg, each from the list the realm offers. Logout tokens use the client’s ID-token algorithm. A fapi2 client never gets RS256.

The public keys are at https://foobar.cvyuh.com/oauth2/jwks. The address is public, and any web page may read it. Each key’s id (kid) is its RFC 7638 thumbprint. The set also carries the realm’s one encryption key ("use": "enc"), which apps encrypt request objects to; a verifier takes only the keys that sign.

The answer says how long it may be cached (Cache-Control: public, max-age=300 by default), and that is what makes rotation safe.

A rotation names one algorithm and the moment the new key starts signing, validFrom. That moment must be at least the publish lead away (an hour by default):

  1. You rotate. The new key is published at once, beside the old one.
  2. Apps and APIs pick it up as their caches of the key set refresh.
  3. At validFrom, the new key starts signing. The old one stays published so the tokens it signed still verify.

Revoking destroys one key version. It leaves the key set, and every token it signed stops verifying: at the realm at once, and at your APIs and gateways as their caches drop it. The key that is signing now can’t be revoked, so to replace a key you don’t trust, rotate first, then revoke the old version.

A verifier that follows three rules never needs you during a rotation:

  • Pick the key by kid. Take the key whose kid matches the token’s header, never “the first key”.
  • Refetch on an unknown kid, once, then refuse the token if the kid is still missing. Don’t refetch more often than every five minutes on unknown kids alone, so a stream of forged tokens can’t make it hammer the realm.
  • Honor Cache-Control. Keep the key set no longer than its max-age.

Every mainstream OAuth and JOSE library does this when given the realm’s issuer or key set address. An app that copied one key into its configuration doesn’t, and must be given the new key before validFrom.

Rotate one algorithm, naming when the new key starts signing:

Terminal window
curl -X PUT https://foobar.cvyuh.com/api/v0/am/keys/v1/signing \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-d '{ "algorithm": "ES256", "validFrom": "<RFC 3339 time, at least the publish lead from now>" }'

The realm answers 204. Rotate each algorithm with its own call.

To see the keys, call GET https://foobar.cvyuh.com/api/v0/am/keys/v1. Each entry gives a key, its version, alg, state and validFrom, and never the key itself:

  • oauth2/signing entries are the signing keys. valid means it signs now, or will from its validFrom; retained means it is kept only to verify what it signed.
  • oauth2/signing/cluster-local entries are the internal signing key.
  • store/encryption entries are the realm’s storage key. Its newest version is valid; older ones are retained only to open what they sealed.

To revoke a version, call DELETE https://foobar.cvyuh.com/api/v0/am/keys/v1/signing/<version>. The realm answers 204. The guides Rotate signing keys and Revoke a signing key take each from start to finish.

The realm holds one more signing key, oauth2/signing/cluster-local: the internal signing key. It signs only tokens that never leave Cvyūh, passed between the parts of your realm’s products. It is ES256, it is never in the published key set, and no app or API of yours ever meets a token it signed.

You never need to touch it. Rotating it (PUT https://foobar.cvyuh.com/api/v0/am/keys/v1/cluster-local, with the same body as a signing key’s) or revoking a version (DELETE https://foobar.cvyuh.com/api/v0/am/keys/v1/cluster-local/<version>) follows the same rules as a signing key, and every part of your realm learns the new key before it signs; nothing you see changes. Do it only if Cvyūh asks you to.

AnswerCauseWhat to do
400, “a rotated key signs too soon”validFrom is sooner than the publish lead; the detail names the earliest time allowedSend a later validFrom
400 on a revocationThe version is signing now, or became the signer within skewSecsRotate first, wait skewSecs past the new key’s validFrom, then revoke
400 on a rotationThe realm holds 100 versions and the oldest is still liveRevoke an old version first
400 on a settings changeThe publish lead no longer exceeds the cache time plus 300 seconds, or skewSecsRaise publishLeadSecs first
400 on the internal keyAn algorithm other than ES256Send ES256
403Your rights don’t include MODIFY on keySettingsAsk for RealmOwner
404 on a revocationNo such version, or it’s already revokedList the keys and check the version

What users see: nothing, during a rotation that keeps to the publish lead. After a revocation, a user whose tokens the revoked key signed is asked to sign in again by their app, or their app refreshes.

All in the realm’s keySettings, except the version cap:

SettingDefaultRangeWhat it sets
rotation.publishLeadSecs360010 to 2,592,000 secondsHow far ahead a new key is published
rotation.skewSecs605 to 300 secondsHow far two clocks may disagree on a key change
publication.maxAgeSecs3000 to 86,400 secondsHow long apps may cache the key set
algorithm.oauth2.idToken["RS256", "ES256"]RS256, ES256, PS256What ID tokens, userinfo answers and logout tokens may be signed with. RS256 always stays
algorithm.oauth2.introspection["RS256", "ES256"]RS256, ES256, PS256What a signed introspection answer may use
Signing-key versions100 per realm, across the three algorithmsCan’t be raisedHow many versions the realm keeps

rotation.publishLeadSecs must exceed publication.maxAgeSecs plus 300 seconds, and must exceed rotation.skewSecs; a lead under 301 seconds therefore needs a maxAgeSecs of 0. Change a setting with PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/keySettings/keySettings, for example { "rotation": { "publishLeadSecs": 7200 } }.

  • An API refuses tokens right after validFrom. It cached the key set before the new key was published, and doesn’t refetch on an unknown kid. Give it the rules in What your apps should do, or raise publishLeadSecs so its cache turns over first.
  • An app refuses every ID token after you added PS256. The client asked for an algorithm its library can’t check. Set its idTokenSignedResponseAlg to one the library supports.
  • Your policy says rotate yearly. Keys never rotate on their own: set a reminder of your own, and follow Rotate signing keys for each algorithm.

Every rotation, import and revocation is recorded on the realm’s audit trail under the administrator who made it, whether it held or was refused, never the key: an UPDATED record for a rotation or import (an import marked imported) and a DELETED record for a revocation, each naming the key and its version. These records aren’t about a user or agent, so no trail answer returns them yet; ask Cvyūh support for them. A change to keySettings is in its change history, at GET https://foobar.cvyuh.com/api/v0/am/objects/v1/keySettings/keySettings/history.

  • You can bring your own key. Once it’s turned on for the realm, a realm signs with a key and certificate chain it supplies: see Bring your own key.
  • A deleted realm’s keys go with it. A deleted realm answers nothing, so nothing it signed can be checked. Its keys are destroyed when the realm is purged; see Realms and sub-realms.