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] Derive the public key from private_key.der on the deprecated key-folder path #2363
Is your feature request related to a problem? Please describe.
When server.token-signing-private-key-file is not set, the server signs its tokens with the key it keeps in etc/conf (deprecated since #2081). On that path it reads the private key from private_key.der and the public key from public_key.der as two separate files (SecurityConfiguration.java:70-76). Nothing checks that they are one pair. If they don't match (for example, one file was replaced by hand), the server starts and logs nothing, but every token it signs fails its own check, so internal tokens get a 401.
The key-file path does not have this problem: it derives the public key from the private key (publicKeyOf, line 128).
This predates #2081 (the folder path read the two files separately before it too), and it fails closed. It was raised in the review of #2081 (#2081 (comment)).
To reproduce, put a private_key.der and a public_key.der from two different openssl genrsa keys in a folder, build new SecurityConfiguration(folder), sign a token with algorithmRSA() and verify it with the same algorithm: verification fails with SignatureVerificationException.
Describe the solution you would like
In SecurityConfiguration(Path configurationFolder), derive the public key from private_key.der with publicKeyOf, as the key-file path does, instead of reading public_key.der.
Keep writing public_key.der when the server generates a key, so a rollback to an earlier release, which reads that file, still works.
Add a row or step to the existing SecurityConfigurationTest: with a mismatched public_key.der, a token signed by the configuration verifies with it.
Additional context
Other follow-ups from the same review are tracked separately: #2364 (a key file path that is a directory), #2365 (a key too small for RS512), #2366 (writing the generated key atomically).
Hi @shba24, I’d like to work on this issue. I’ve reviewed the deprecated key-folder behavior and will update SecurityConfiguration to derive the public key from private_key.der, while keeping public_key.der generation for backward compatibility. I’ll also add regression coverage for mismatched key files.
Activity
yajneshx94 commentedon Nov 24, 2026
Hi @shba24, I’d like to work on this issue. I’ve reviewed the deprecated key-folder behavior and will update SecurityConfiguration to derive the public key from private_key.der, while keeping public_key.der generation for backward compatibility. I’ll also add regression coverage for mismatched key files.
shba24 commentedon Nov 24, 2026
Thank you picking this up @yajneshx94