Appendix D. Notes on Key Selection
Appendix D. Notes on Key Selection
This appendix provides notes on algorithms that applications can use to select the key to be used for validating a JWS among a set of potential keys.
Key Selection Considerations
When multiple keys are available to an application, the following Header Parameters can assist in key selection:
-
"kid" (Key ID): Provides a hint about which key was used. Applications can match this with the "kid" parameter in JWK representations of candidate keys.
-
"jku" (JWK Set URL): Points to a set of JSON-encoded public keys, one of which corresponds to the signing key.
-
"jwk" (JSON Web Key): Contains the actual public key used for signing.
-
"x5u" (X.509 URL): Points to an X.509 certificate or certificate chain.
-
"x5c" (X.509 Certificate Chain): Contains the X.509 certificate or certificate chain directly.
-
"x5t" (X.509 Certificate SHA-1 Thumbprint): Contains a thumbprint of the certificate.
-
"x5t#S256" (X.509 Certificate SHA-256 Thumbprint): Contains a SHA-256 thumbprint of the certificate.
Selection Algorithm
A typical key selection algorithm might:
- Check if "kid" is present and matches a known key ID
- If "jwk" is present, use that key directly
- If "jku" is present, fetch the JWK Set and find the matching key
- If X.509 parameters are present, validate and extract the key from the certificate
- Fall back to application-specific key determination methods
Applications MUST validate that the selected key is appropriate for use with the algorithm specified in the "alg" Header Parameter.