JSON Web Key Sets (JWKS)
Overview
A JSON Web Key Set (JWKS) is a set of keys that contain a list of cryptographic keys that can be used either for signature verification or for encryption. Each key in the JWKS is stored in the JSON Web Key format, as specified in RFC 7517.
In order to integrate with Singpass, you are required to register your JWKS with us. The same JWKS can be reused across multiple Singpass integrations.
Conversely, we also broadcast our JWKS at https://id.singpass.gov.sg/.well-known/keys. These are our public keys used for signing, and you should use them to verify the signature in both the ID token and the Userinfo response.
Purpose of JWKS
The keys that you provide in your JWKS will be used for the following:
- Verification of your client assertions (they are signed by one of your private keys). This is done during both the Pushed Authorization Request and Token Exchange 
- Encryption of the ID Token 
- Encryption of the Userinfo response 
Registration of JWKS
When registering your JWKS with us, you have two options:
- Directly register the JWKS with us as a JSON object in your app configuration 
- Host the JWKS on a publicly accessible URL, and register that URL with us in your app configuration. 
Requirements for JWKS
General
- Your JWKS must have at least one encryption key and one signing key. 
- All of the keys in your JWKS must not expose your private key. Specifically, it must not contain the - dproperty, which represents the private key. Exposure of this property is a critical security vulnerability.
- All of the keys in the JWKS must: - Have unique key IDs in the - kidfield. Additionally, any new keys should not reuse previously-used key IDs.
- Contain a - ktyof- EC
- Contain one of the following - crvvalues:- P-256
- P-384
- P-521
 
 
- If your JWKS is hosted at a URL: - The URL must be publicly accessible at all times 
- It should respond as fast as possible, as the user experience of your users will be affected if your JWKS endpoint takes a long time to respond. In the worst case, it must respond within 3 seconds; otherwise, your users will fail to authenticate with us. 
 
Signing Keys
- Must have a - usevalue of- sig
Encryption Keys
- Must have a - usevalue of- enc
- Must contain one of the following - algvalues:- ECDH-ES+A128KW
- ECDH-ES+A192KW
- ECDH-ES+A256KW
 
Key Rotation
You should rotate your keys at least once a year. You will be able to rotate your keys without downtime. The process for rotating encryption keys and signing keys is slightly different, and will be outlined below.
Signing Keys
- Generate your new signing key pair, and add the public signing key to your JWKS without removing the old public signing key. The newly added key must have a different - kidfrom any of the existing keys.
- Wait for 1 hour. This ensures that our cache has expired and that we will have fetched your new keys, which we can then use to verify requests that you sign using your new key. 
- Start signing your requests using your new private key. 
- Remove the old public signing key from your JWKS. 
Encryption Keys
- Generate your new encryption key. 
- Update your application such that it can perform decryption using either the old or the new key, depending on the - kidvalue in the JWE header.
- Replace the old key in your JWKS with the new key. The new key should have a different - kidfrom the old one.
- Wait for one hour. This ensures that our cache has expired, and that we will only perform encryption using your new key. 
- Remove the old encryption key from your JWKS. 
Last updated
Was this helpful?