Q17: What is a JSON Web Key Set (JWKS) and how is key rotation handled dynamically?

Difficulty:AdvancedTopic:Cryptography

A JWKS (RFC 7517) is a set of public keys represented as a JSON structure exposed by an Authorization Server at a public URL (e.g., /.well-known/jwks.json).

Resource Servers consume JWKS endpoints to dynamically fetch public keys needed to verify incoming RS256/ES256 signatures.

Key Rotation Process:

  • Each public key in a JWKS is assigned a unique Key ID (kid).
  • JWT headers contain a matching kid header property indicating which key was used to sign the token.
  • During key rotation, the Auth Server introduces a new key pair, publishes the new public key in the JWKS, and signs new tokens with the new kid while keeping old keys in the JWKS for legacy tokens.
JWKS Response JSON Payload
{
  "keys": [
    {
      "kty": "RSA",
      "use": "sig",
      "alg": "RS256",
      "kid": "auth-key-2026-v1",
      "n": "u1W_z...",
      "e": "AQAB"
    }
  ]
}
💡 Resource servers match the incoming JWT header kid parameter against the keys array to pick the correct public key.
Key Takeaways
  • JWKS enables dynamic public key distribution and seamless cryptographic key rotation.
  • APIs locate verification keys by matching the kid property in the JWT header against JWKS entries.