Skip to content

[Server] Reject a token signing key too small for RS512 when it is loaded #2365

Done

Description

@shba24

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.

Raised in the review of #2081 (#2081 (comment)). The behavior predates that PR.

Describe the solution you would like

  1. 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).
  2. 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.

Activity

  1. added
    enhancement
    good first issue
    on Nov 24, 2026
  2. Maneet7805 commented on Nov 24, 2026

    @Maneet7805
    Contributor

    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

  3. added a commit that references this issue on Nov 30, 2026
    80b1c5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementgood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions