8000 Raise generated cache-transport RSA keys to 3072 bits and allow ECDSA by ahus1 · Pull Request #55224 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Raise generated cache-transport RSA keys to 3072 bits and allow ECDSA - #55224

Draft
ahus1 wants to merge 10 commits into
keycloak:mainfrom
ahus1:is-54496-jgroups-rsa-key-size
Draft

ahus1 wants to merge 10 commits into
keycloak:mainfrom
ahus1:is-54496-jgroups-rsa-key-size

Conversation

@ahus1
@ahus1 ahus1 commented Nov 16, 2026 •
Copy link
Copy Markdown
Member

Closes #54496

The generated cache-transport certificate follows BSI TR-02102-2, which asks for RSA keys of at least 3000 bits and deprecates PKCS#1 v1.5 signatures.

Decisions and assumptions

  • The default is RSA 3072 signed with RSASSA-PSS. Only the JGroups certificate opts into PSS; realm keys, client credentials and other callers of the shared certificate utilities keep PKCS#1 v1.5 to avoid breaking relying parties.
  • The SPI options algorithm (RSA default, or ECDSA), key-size (default 3072, minimum 2048) and curve (secp256r1 default, secp384r1, secp521r1) are added to the jgroups-mtls SPI. Invalid values fail at startup. The CLI options are expected to be removed in a future version, so this is meant to be backported to allow a graceful migration.
  • On startup a node compares the stored certificate with the configured key specification and regenerates it on mismatch. The replacement is conditional on the mismatch still existing, so concurrent nodes regenerate once. Running nodes pick up the new certificate through the existing trust-manager failure reload; no new notification was added, so a rolling upgrade can cause short-lived connection retries.
  • The private key is now stored as PKCS#8, as the existing PEM utilities write EC keys as SEC1 and cannot read them back.
  • The Arquillian FIPS integration tests now run with clustered caches (--cache=ispn) so that they exercise certificate generation in FIPS mode; the Arquillian local mode is left in place and can be removed in a follow-up. The new-framework FIPS suites stay on local caches, as tests like LoginTest assume cookies without a cluster route.
  • The clustered ECDSA test only asserts that two nodes form a cluster
  • The startup migration is tested in the new test framework in tests/clustering against a two-node cluster. JGroupsCertificateRotationClusterTest is migrated from the Arquillian testsuite for this, and the Arquillian version is removed. To run code on a specific node, run-on-server now works with the clustered server: the containers load the test classes from the host via host.testcontainers.internal, configured through the test-class-url option of the run-on-server provider, and the load balancer selects the node. Stopping the coordinator needs its own cluster, so it is a separate test class. The tests skip on stateless clusters, as those nodes do not form one cluster.
  • The upgrade note is in changes-27_0_0.adoc; a backport needs to move it to the matching version file.
  • The mixed-version job only runs the org.keycloak.tests.compatibility package, selected through MixedClusterTestSuite. Its old node is an older patch release that does not know the new key options, so the certificate tests must not run there.

Closes keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
ahus1 and others added 3 commits November 16, 2026 14:17
Closes keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Adds the startup check, logs the active certificate, and adds docs and release notes.

Closes keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Closes keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
@ahus1
ahus1 force-pushed the is-54496-jgroups-rsa-key-size branch 2 times, most recently from 0d263ba to 98b4314 Compare November 16, 2026 13:50
ahus1 and others added 2 commits November 16, 2026 15:34
Closes keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Closes keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
@ahus1
ahus1 force-pushed the is-54496-jgroups-rsa-key-size branch from 98b4314 to 3966750 Compare November 16, 2026 14:34
@ahus1
ahus1 requested a balanced review from Copilot November 16, 2026 15:24
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Database-backed startup migration tests are missing for larger, smaller, and unchanged keys and concurrent startups, leaving committed-certificate convergence and alias preservation unverified.

1 open issue
What changed in this PR

Strengthens Keycloak’s automatically generated cache-transport certificates for #54496, without changing realm keys or user-supplied certificates.

Changes:

  • Defaults to RSA-3072 with RSASSA-PSS, adds RSA/ECDSA configuration, and replaces stored certificates on startup when their keys do not match.
  • Adds opt-in PSS signing to shared certificate utilities and stores transport private keys as PKCS#8.
  • Updates documentation, adds cryptographic and cluster-formation tests, and enables clustered caches in Arquillian FIPS tests.
File Description
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​adapter/​servlet/​SAMLServletAdapterTest.java Removes cluster routes before decoding session cookies.
testsuite/​integration-arquillian/​tests/​base/​src/​main/​java/​org/​keycloak/​testsuite/​arquillian/​containers/​AbstractQuarkusDeployableContainer.java Supports default clustered-cache configuration.
tests/​clustering/​src/​test/​java/​org/​keycloak/​tests/​clustering/​EcdsaCacheTransportCertificateTest.java Adds ECDSA cluster-formation coverage.
model/​infinispan/​src/​test/​java/​org/​keycloak/​jgroups/​certificates/​UtilsTest.java Tests generation, key matching, and legacy private-key loading.
model/​infinispan/​src/​main/​java/​org/​keycloak/​jgroups/​certificates/​Utils.java Generates configured transport keys and requests PSS signing.
model/​infinispan/​src/​main/​java/​org/​keycloak/​jgroups/​certificates/​KeySpec.java Defines RSA/ECDSA configuration, validation, and matching.
model/​infinispan/​src/​main/​java/​org/​keycloak/​jgroups/​certificates/​JGroupsCertificate.java Stores private keys as PKCS#8.
model/​infinispan/​src/​main/​java/​org/​keycloak/​jgroups/​certificates/​DefaultJGroupsCertificateProviderFactory.java Exposes and reads certificate provider options.
model/​infinispan/​src/​main/​java/​org/​keycloak/​jgroups/​certificates/​DatabaseJGroupsCertificateProvider.java Replaces mismatched stored certificates during startup.
model/​infinispan/​pom.xml Adds the default crypto provider for tests.
docs/​guides/​server/​caching.adoc Documents stronger defaults and configuration behavior.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Explains migration, retries, and configuration options.
docs/​documentation/​release_notes/​topics/​27_0_0.adoc Announces stronger cache-transport certificates.
crypto/​fips1402/​src/​test/​java/​org/​keycloak/​crypto/​fips/​test/​BCFIPSCertificateUtilsProviderTest.java Tests PSS and ECDSA certificate signing.
crypto/​fips1402/​src/​main/​java/​org/​keycloak/​crypto/​fips/​BCFIPSCertificateUtilsProvider.java Adds opt-in PSS signing for the FIPS provider.
crypto/​elytron/​src/​main/​java/​org/​keycloak/​crypto/​elytron/​ElytronCertificateUtilsProvider.java Adds PSS signature selection for Elytron.
crypto/​default/​src/​test/​java/​org/​keycloak/​crypto/​def/​test/​BCCertificateUtilsProviderTest.java Tests PSS and preserved PKCS#1 signing behavior.
crypto/​default/​src/​main/​java/​org/​keycloak/​crypto/​def/​BCCertificateUtilsProvider.java Adds opt-in PSS signing for the default provider.
common/​src/​main/​java/​org/​keycloak/​common/​util/​CertificateUtils.java Exposes the optional PSS signing overload.
common/​src/​main/​java/​org/​keycloak/​common/​crypto/​CertificateUtilsProvider.java Extends the certificate-provider signing contract.
.github/​scripts/​run-fips-it.sh Enables clustered caches for Arquillian FIPS tests.

Review effort: Balanced

ahus1 and others added 2 commits November 16, 2026 16:56
…ration tests

Run the test on the new test framework by letting run-on-server reach the
containers of a clustered server, and cover the certificate replacement on
startup for larger, smaller and different keys, and concurrent startups.

Relates to keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Relates to keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The rotation tests fail in stateless and mixed-version CI configurations, and their cleanup can leave shared-cluster certificates inconsistent with the server configuration.

3 open issues
1 resolved since last review

Review effort: Balanced

ahus1 and others added 2 commits November 16, 2026 17:41
… compatibility tests in mixed clusters

The stateless nodes form independent clusters, so multi-member assertions
time out. Mixed-version clusters use released images without the key
specification, so only the compatibility tests run there. Reload the
certificate on all nodes before restoring it, so that the coordinator
knows the alias that was written by the test.

Relates to keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Relates to keycloak#54496

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raise generated cache-transport RSA keys to 3072 bits

2 participants

0