Skip to content
PlatformMarkdown

Bring your own key

Sign your realm's tokens with a key your organization made, and publish its certificate chain beside it.

AvailableAPIRFC 7517, RFC 5280, RFC 7468

Some organizations must sign with a key they generated themselves, under their own key ceremony, or must publish a certificate that chains to their own authority so their partners can check it. Bring your own key lets a realm do that: you import a signing key and its certificate chain, and from the moment you name the realm signs with it, the same way it would sign with a key it made.

  • Turned on by Cvyūh. Bring your own key is turned on per realm, by Cvyūh, on request. A realm without it signs only with keys the realm makes.
  • Privilege: MODIFY on the realm’s keySettings, which RealmOwner gives.
  • Where: the API.
  • First: the key as a PKCS#8 PEM, and optionally its certificate chain as PEMs, leaf first. Your session is in $CVYUH_SESSION (Call the API).

An imported key is a new version of the realm’s signing key for one algorithm. It goes through the same rotation as any other: published at once, signing from its validFrom, and kept after it is replaced so the tokens it signed still verify. You revoke it the same way too.

The certificate chain you supply is published with the key, in its x5c member in the realm’s key set, so a verifier that wants a certificate path can build one. The chain is optional.

Terminal window
curl -X PUT https://foobar.cvyuh.com/api/v0/am/keys/v1/signing/imported \
-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>",
"privateKey": "-----BEGIN PRIVATE KEY-----\n…\n-----END PRIVATE KEY-----",
"certificateChain": [
"-----BEGIN CERTIFICATE-----\n…leaf…\n-----END CERTIFICATE-----",
"-----BEGIN CERTIFICATE-----\n…issuer…\n-----END CERTIFICATE-----"
]
}'

The realm answers 204. The key then appears in GET https://foobar.cvyuh.com/api/v0/am/keys/v1 like any other version, and in the published key set at once.

FieldWhat it is
algorithmES256, RS256 or PS256: the algorithm the key signs with
validFromWhen it starts signing, as an RFC 3339 time, at least the publish lead from now
privateKeyThe key, as a PKCS#8 PRIVATE KEY PEM
certificateChainOptional. The chain for it, leaf first, each a CERTIFICATE PEM
AnswerCauseWhat to do
403, “this realm holds no grant to bring its own key”Not turned on for the realmAsk Cvyūh to turn it on
400, “privateKey does not read” or “certificateChain does not read”Not a PEM of the right kindSend a PKCS#8 PRIVATE KEY PEM, and CERTIFICATE PEMs
400, “the supplied key is refused”The key doesn’t fit the algorithmES256 needs a P-256 key; RS256 and PS256 need RSA of at least 2,048 bits
400 on the chainThe leaf isn’t for this key, or isn’t valid at validFromSend the key’s own certificate first, valid at validFrom
400, “a rotated key signs too soon”validFrom is sooner than the publish leadSend a later validFrom
400The realm holds 100 versions and the oldest is still liveRevoke an old version first
WhatDefaultCan it change
Bring your own keyOffCvyūh turns it on per realm, on request
Key sizesP-256 for ES256; RSA 2,048 bits or more for RS256 and PS256No
Signing-key versions, imported ones included100 per realmNo
Publish lead3,600 secondskeySettings.rotation.publishLeadSecs; see Signing keys
  • A partner can’t build a path to your authority. The chain was left out, or doesn’t reach an authority they trust. Import the key again as a new version, with the full chain.
  • You need the key back. Keep your own copy: no API returns an imported key. Reading back a key you brought is planned.

An import is recorded on the realm’s audit trail as an UPDATED record for the signing key, under the administrator who made it, marked imported, with whether it held; the key never is. See Signing keys.

  • Withdrawing the grant closes the route, not the key. The imported key in force keeps signing until you rotate to a new one.
  • The leaf certificate must be for this key. Its first certificate must name the key’s public half.