Repository navigation
fix: use configured crypto provider to read generated truststores #54017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vmuzikar
merged 5 commits into
keycloak:main
from
slaskawi:fix/truststore-crypto-provider
Oct 26, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
895add0
fix: use configured provider to read system truststores
slaskawi 5062431
Merge remote-tracking branch 'upstream/main' into fix/truststore-cryp…
slaskawi 1ba8cc0
test: simplify truststore provider regression coverage
slaskawi 7990c5b
Merge remote-tracking branch 'upstream/main' into fix/truststore-cryp…
slaskawi ea807e3
Remove internal truststore release note
slaskawi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider adding an explicit test for what this PR is actually trying to fix: same provider is used for writing and reading. I believe we're missing that at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current tests explicitly check the system property as well as the provider used to read the generated store:
In
services/src/test/java/org/keycloak/truststore/FileTruststoreProviderFactoryTest.java,generatedTruststoreIsReadWithItsWriterProvider():TruststoreBuilder.setSystemTruststore(...)to generate and save the truststore. That production method publishes the writer'struststore.getProvider().getName()asjavax.net.ssl.trustStoreProvider.FileTruststoreProviderFactorywithout an explicit truststore configuration, so it loads the generated store using the system properties.System.getProperty(TruststoreBuilder.SYSTEM_TRUSTSTORE_PROVIDER_KEY)equals"BC"and the loaded store'sgetProvider().getName()also equals"BC".In
crypto/fips1402/src/test/java/org/keycloak/crypto/fips/test/FIPS1402KeystoreTypesTest.java,generatedTruststoreIsReadWithItsWriterProvider()exercises the same generation-and-readback path, explicitly asserts both the property and reader provider equal"BCFIPS", and checks the preferred generated store type and retained certificates.Separately,
testSetSystemTruststoreUsesPkcs12ByDefault()andtestSetSystemTruststoreUsesPreferredBcfksType()inservices/src/test/java/org/keycloak/truststore/TruststoreBuilderTest.javaalready assert the generated path, type, and password properties. Those two tests do not currently assert the provider property; adding that assertion would be straightforward, but the explicit provider-property checks are already in the readback tests above.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slaskawi Thanks for the reply. Yes, we're checking the indirect effects the truststore logic. It could still happen that e.g.
FileTruststoreProviderFactoryignoresjavax.net.ssl.trustStoreProvider, and we might not notice that from the test, or that the builder uses a different provider that what is then stored injavax.net.ssl.trustStoreProvider. But that's a very marginal risk. Hence approving, thanks!