You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Server] Reject a token signing key too small for RS512 when it is loaded #2365
Is your feature request related to a problem? Please describe.
The server signs its tokens with RS512, which cannot sign with a very small RSA key. A 512-bit key in server.token-signing-private-key-file (or in the key folder) loads without an error, and startup then fails when the server signs its first token:
SignatureGenerationException: The Token's Signature couldn't be generated when signing using the Algorithm: SHA512withRSA
caused by InvalidKeyException: Key is too short for this signature algorithm
The message doesn't name the key file. Every other unusable key fails while it is loaded, with a message that names the file.
When the key is loaded in SecurityConfiguration, check that it can sign with RS512, and if not, fail with a message that names the file and the key size, and says to create a 2048-bit key (openssl genrsa -out private_key.pem 2048).
Add a row for a 512-bit key to the existing SecurityConfigurationTest tests of unusable key files.
Additional context
Keys of 1024 bits work today, so requiring 2048 bits would break setups that work now. If the project wants a 2048-bit minimum, that is a separate behavior change to discuss in this issue first.
Hi @shba24, I'd like to work on this issue. I'll add a check in SecurityConfiguration where the private key is read: it will try to sign with SHA512withRSA, and if the key is too short it will fail at load time with a message naming the key file and its size and suggesting openssl genrsa -out private_key.pem 2048. I'll keep 1024-bit keys working, since the issue says they work today, and add a 512-bit row to the existing SecurityConfigurationTest for unusable key files.
Activity
Maneet7805 commentedon Nov 24, 2026
Hi @shba24, I'd like to work on this issue. I'll add a check in SecurityConfiguration where the private key is read: it will try to sign with SHA512withRSA, and if the key is too short it will fail at load time with a message naming the key file and its size and suggesting
openssl genrsa -out private_key.pem 2048. I'll keep 1024-bit keys working, since the issue says they work today, and add a 512-bit row to the existing SecurityConfigurationTest for unusable key files.take
[Server] Reject a token signing key too small for RS512 when it is lo…