What a JSON Web Key Set is
A JSON Web Key Set (JWKS, RFC 7517) is a JSON object with one member, keys, holding a list of JSON Web Keys. Each key describes one public key: its type, its numbers, and how it may be used.
Identity providers publish their public keys as a JWKS so that anyone can verify the tokens they sign. A client or API downloads the set, then picks the right key for each token by the kid in the token’s header.
What is inside a key
Every JWK has kty, the key type. The other members depend on the type.
| Member | Meaning | Example |
|---|---|---|
kty | Key type | RSA, EC, OKP, oct |
kid | Key id, used to pick the key | Any string unique in the set |
use | Intended use | sig for signing, enc for encryption |
alg | The one algorithm the key is for | RS256, ES256, RSA-OAEP |
n, e | RSA modulus and exponent | Base64url numbers |
crv, x, y | EC curve and point | P-256 with two coordinates |
x5c | Certificate chain, first entry holds this key | Standard Base64 DER |
x5t, x5t#S256 | SHA-1 and SHA-256 thumbprints of the certificate | Base64url hashes |
Private keys add members such as d, p and q. A published key set must never contain them.
{
"keys": [
{
"kid": "sample-acme-rs256",
"kty": "RSA",
"alg": "RS256",
"use": "sig",
"n": "6SoS-K45f5Qe…",
"e": "AQAB"
}
]
}What this viewer shows
- Each key’s
kid, type, algorithm and use, with a label for signing or encryption keys. - The key size: RSA modulus bits, EC curve, or symmetric key length.
- The RFC 7638 thumbprint, a stable SHA-256 identifier computed from the key itself.
- For keys with
x5c, the certificate’s subject and expiry date. - Whether
x5tandx5t#S256match the certificate. - Warnings for missing or duplicate
kidvalues, short RSA keys, and private parameters in a public set.
It reads the JSON you paste; it does not fetch URLs. Open your certs endpoint in a browser tab and copy the response.
How to read a key set
- Open the key set URL in your browser. For Keycloak it is
https://<host>/realms/<realm>/protocol/openid-connect/certs. - Copy the whole JSON and paste it into the box.
- Check the key count in the panel title. A realm usually lists more than one key.
- For each key, read the use and algorithm, then the certificate expiry if there is one.
- Read any warnings. Private parameters in a published set are a serious problem.
Keycloak’s certs endpoint
Every Keycloak realm publishes its key set at /realms/<realm>/protocol/openid-connect/certs. The realm’s discovery document, at /realms/<realm>/.well-known/openid-configuration, gives the same URL as jwks_uri.
A new realm has an RSA signing key for RS256 and an RSA encryption key for RSA-OAEP, so the set normally shows at least one sig key and one enc key. Keycloak usually includes the key’s self-signed certificate in x5c, with the realm name as its subject.
HMAC and AES keys that a realm also holds are secret and never appear in the set.
Where the keys come from
In the admin console, Realm settings, Keys lists each key with its algorithm, type, kid, use and priority. The Providers tab shows the key providers that create them. When a realm has several keys for the same algorithm, the active key with the highest priority signs new tokens.
During a key rotation
To rotate, add a new key provider with a higher priority. New tokens then carry the new kid. Keep the old key enabled but passive until every token it signed has expired, so the set keeps listing it and older tokens still verify. Then disable or delete it.
Use cases
Configuring an API or gateway
Before you point a resource server at a jwks_uri, check what it will find: which algorithms, which key types, and whether any key would confuse a library that ignores use.
Answering “which key signed this?”
Copy the kid from a token’s header and look for it in the list. The key id matcher does this automatically and verifies the signature.
Auditing a key set
Look for short RSA keys, missing key ids, expired certificates, and keys nobody can explain. Each is a reason to rotate.
Common problems
- The verifier picks an encryption key: some libraries ignore
use. Make sure yours selects bykidand only usessigkeys for signatures. - The token’s
kidis not in the set: the token came from another realm or server, or the verifier cached an old copy of the set. - Two keys share a
kid: a client cannot tell them apart and may pick the wrong one. - The certificate in
x5chas expired: Keycloak’s certificate is self-signed and most verifiers use only the key, but some libraries check the certificate dates. Rotate if yours does.
Fetching the set from the command line
You can also read a realm’s key set with curl and jq, which is handy on a server or in a script.
curl -s https://auth.example.com/realms/acme/protocol/openid-connect/certs \
| jq '.keys[] | {kid, kty, alg, use}'Paste the full response here when you also want sizes, thumbprints and certificate dates.
Checking a key set before going live
- Confirm every signing algorithm your realm or clients use has a matching
sigkey in the set. - Confirm no key carries private members such as
d. - Confirm every key has a unique
kid. - Note the certificate expiry of each key, in case a verifier checks it.
- Verify one fresh token against the set with the signature verifier.
A key set that changes without anyone announcing it is worth a closer look. Compare today’s list of key ids with the one your verifiers cached, and make sure every new key was expected.
Keep a copy of the checked set with the date, so the next review can tell what changed.
Key sets from other providers
Every OpenID Connect provider publishes a key set at the jwks_uri in its discovery document, so this viewer works for any of them. When Keycloak brokers another provider, the identity provider settings can point to that provider’s key set to validate its tokens. Pasting the provider’s set here first shows which algorithms and key types Keycloak will have to handle.
Security notes
A JWKS is public by design. Publishing public keys is safe; publishing a private parameter such as d gives away the key. If the viewer warns about private parameters in a published set, treat the key as compromised and replace it.
Fetch key sets only over HTTPS and only from the issuer you trust. A verifier that downloads keys from a URL inside a token can be tricked into trusting an attacker’s keys.
Best practices
- Give every key a unique
kid, and setuseandalg. - Use RSA keys of 2048 bits or more, or EC keys on P-256 or larger curves.
- Cache the set in your verifiers and refresh it when an unknown
kidarrives, with a limit on how often. - Rotate keys on a schedule and keep the old key listed until its tokens expire.