Repository navigation
Conversation
When no javax.net.ssl.trustStore is configured, merging the default truststore loaded the JRE cacerts as PKCS12 with no password. On distributions that ship cacerts as JKS, such as Red Hat OpenJDK, providers that do not read JKS content as PKCS12 reject it. With BCFIPS in non-strict mode the server then fails to start whenever truststore-paths is set. Try the JRE default keystore type, JKS and PKCS12 in turn, with no password and then the well-known default one. An explicitly configured javax.net.ssl.trustStore is loaded as before. Closes keycloak#28526 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Andre F de Miranda <trixpan@users.noreply.github.com>
Contributor
Author
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, preserves explicit truststore configuration, and includes targeted regression coverage with no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes JRE truststore loading across keystore formats, addressing startup failures with Red Hat OpenJDK and non-strict FIPS mode.
Changes:
- Tries fallback formats and passwords for JRE truststores while preserving explicit configuration behavior.
- Reports attempted formats when loading fails.
- Adds a regression test for JKS
cacertswith format compatibility disabled.
| File | Description |
|---|---|
| services/src/test/java/org/keycloak/truststore/TruststoreBuilderTest.java | Tests merging a JKS JRE truststore. |
| services/src/main/java/org/keycloak/truststore/TruststoreBuilder.java | Adds format and password fallbacks for JRE truststores. |
Review effort: Balanced
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #28526
Summary
When no
javax.net.ssl.trustStoreis configured,TruststoreBuilder.includeDefaultTruststoreloads the JREcacertsas PKCS12 with no password. Red Hat OpenJDK shipscacertsas a JKS keystore (a symlink to/etc/pki/ca-trust/extracted/java/cacerts). Providers that don't read JKS content as PKCS12 reject it, BCFIPS among them. As a result, a server started with--features=fips --fips-mode=non-strictand anytruststore-pathsfails to start:--truststore-kubernetes-enabled=falsedoesn't avoid this, because the merge still runs whenevertruststore-pathsis set. This differs from the case discussed in #28526: here the JKS file is the JRE's owncacerts, not a truststore the user passed totruststore-paths.This change:
changeit.javax.net.ssl.trustStoreexactly as before.Testing
TruststoreBuilderTest.testJksDefaultTruststoreIsMergedgenerates a JKScacertsat runtime and setskeystore.type.compat=false. That setting makes the JDK reject JKS content loaded as PKCS12, as BCFIPS does. The test fails without the fix and passes with it../mvnw test -pl services -Dtest=TruststoreBuilderTest,FileTruststoreProviderFactoryTest: 18 tests pass../mvnw spotless:check -pl servicesEnd to end: a distribution built from this branch, run in a UBI9 container with Red Hat OpenJDK 25, BCFIPS and a faked
/proc/sys/crypto/fips_enabled:--truststore-paths=<pem>--truststore-paths=<pem>truststore-pathsRelated: #54143 works around this in
.github/scripts/run-fips-it.sh. The workaround can be removed once this is merged.AI assistance
This PR was developed with assistance from Claude Code. I reviewed and understand the submitted changes.
🤖 Generated with Claude Code