Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

JWKs, key sets, and key IDs

A verifier needs the issuer's public key written in a form it can read and pick from. This lesson reads one key as JSON, explains the members that decide how it may be used, shows why a verifier never takes its key from the token, and covers the caching that lets a rollover work.

A key written as JSON

Storing and using keys showed Lab Photos publishing its public keys at an address verifiers read, as a JSON Web Key Set. A JSON Web Key (JWK) is a single public key written as JSON, and a JWK Set (JWKS) is the keys array that holds several. This is the entry for the key that signed Ava's token in Inside a JWT:

{
  "kty": "EC",
  "crv": "P-256",
  "x": "iIUYwDjgHwDpHukFHekD8AktnF6NISSc0f1vuntIkyE",
  "y": "kVMlGl5cOYhMPJYgfH0ab2MvuFatOFlfG51SViuAu88",
  "use": "sig",
  "alg": "ES256",
  "kid": "photos-2026-10"
}

The kty, the key type, decides which other members carry the key itself. An EC key, the elliptic-curve type ES256 uses, has a curve name crv and the two point coordinates x and y. An RSA key carries the modulus n and exponent e instead. EdDSA keys use the type OKP, which carries crv and a single coordinate x. What a public JWK never carries is a private member: the d value, the secret number that signs. A d in a published set is a leaked private key.

What the other members say

The remaining members describe how the key may be used, and a verifier should honour them.

  • use separates signing keys (sig) from encryption keys (enc). A verifier checking a signature must pick a sig key and never an enc one. key_ops is a finer version of the same idea, listing the exact operations a key is for, such as verify; a key should carry use or key_ops, not both.
  • alg, when present, pins the key to one algorithm. With the allowlist from Choosing and enforcing algorithms, this is what stops a public RSA key being misused as an HMAC secret.
  • kid is the key identifier a token's header names, so a verifier can pick the matching entry without trying each key in turn.

A kid is only a label the issuer chose, and it means nothing outside that issuer's own set. Two unrelated providers can both label a key photos-2026-10. So a verifier never selects a key by kid alone: it decides whose set it is reading first, from the issuer it trusts, then finds the kid inside that set.

A more durable name for a key is its thumbprint: a hash computed from the key's own members by the fixed recipe in RFC 7638. The recipe takes only the members that define the key, in a fixed order with no extra spaces, and hashes them with SHA-256. The same public key always gives the same thumbprint, whatever kid anyone attaches, so a thumbprint is how a verifier can pin a specific key or recognize the same key across sets.

Headers that offer their own key

A JWS header can carry a key, or an address to fetch one from, instead of a plain kid. These parameters exist for narrow, agreed uses, and they are a classic trap when a verifier honours them from a token it hasn't yet trusted:

Key-bearing header parameters (RFC 8725)
HeaderWhat it offersThe trap
jwkA public key, embedded in the headerThe token supplies the key that checks it, so any token verifies against its own key.
jkuA URL to fetch a key set fromThe verifier fetches a key set the sender controls, and can be steered into requests to internal addresses.
x5uA URL to fetch a certificate fromThe same, with a certificate.
x5cA certificate chain, embedded in the headerThe token supplies a chain; a verifier that doesn't check it against a trusted root trusts whatever is there.

The rule follows from the earlier lessons: a token must not choose its own judge. A verifier finds the key from the issuer it already trusts, at that issuer's configured key-set address, and ignores a key or URL the token hands it. Where x5c or a remote set is genuinely part of a profile, the verifier accepts it only after checking it against a trust anchor it already holds, exactly as Validating a certificate checks a chain against a trusted root.

Caching the key set

Fetching the key set on every token would be slow and would tie the verifier's health to the issuer's, so a verifier keeps a copy and reuses it. The question a cache raises is how it learns a new key. Storing and using keys described the rotation stages: the issuer publishes the new key, keeps the old one until its last token expires, then retires it. The cache is what lets a verifier follow those stages without being told.

When a token names a kid the cached set doesn't hold, the verifier fetches the set again, once, from the issuer's configured address. That refetch finds the newly published key. Two limits keep it safe. The refetch is bounded, so a flood of tokens carrying made-up kid values can't become a flood of requests to the issuer. And the key is added only from the issuer's own configured set, never from a jku or jwk in the token, so the refresh discovers announced keys without ever changing whose keys the verifier trusts. A token whose kid is in neither the cache nor the refetched set is refused, which is exactly what happens to the old key once the issuer retires it.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

A token's header carries a jku pointing at a key set on a server the receiver has never heard of. How should a verifier treat it? 1 of 3

Choose one answer.

Two unrelated issuers each publish a key with kid 2026-09. What does that tell a receiver? 2 of 3

Choose one answer.

A verifier wants to recognise one specific public key even if its issuer relabels it with a different kid. What identifies the key reliably? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity