8000 fix: allowing cacerts and passwordless pkcs12 in non-strict by shawkins · Pull Request #54394 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

fix: allowing cacerts and passwordless pkcs12 in non-strict - #54394

Merged
vmuzikar merged 3 commits into
keycloak:mainfrom
shawkins:iss28526
Nov 2, 2026
Merged

vmuzikar merged 3 commits into
keycloak:mainfrom
shawkins:iss28526

Conversation

@shawkins
@shawkins shawkins commented Oct 27, 2026 •
Copy link
Copy Markdown
Contributor

closes: #54430

Original was targeting this at #28526 because of #54171 - but a new issue is warranted as it clearly articulates the scenario.

This comment was marked as outdated.

@shawkins
shawkins force-pushed the iss28526 branch 2 times, most recently from eda6e2d to 25d46ef Compare October 28, 2026 19:00
@shawkins
shawkins marked this pull request as ready for review October 28, 2026 19:03
@shawkins
shawkins requested review from a team as code owners October 28, 2026 19:03
Copilot AI balanced review requested due to automatic review settings October 28, 2026 19:03
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.

🟢 Approval recommended

No active review issues are reported for the passwordless PKCS12 truststore fallback.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@shawkins
shawkins requested a review from Pepo48 October 28, 2026 20:30
Pepo48
Pepo48 previously approved these changes Oct 29, 2026
@Pepo48 Pepo48 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.

Looks good, thanks Steve.

@shawkins
shawkins requested review from a team and vmuzikar October 29, 2026 13:04
// passwordless pkcs12 is not supported by all providers, try SUN
if (StringUtil.isNullOrEmpty(password) && StringUtil.isNullOrEmpty(provider) && PKCS12.equalsIgnoreCase(type)) {
try {
return KeystoreUtil.loadKeyStore(path, password, type, "SUN");
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.

I'm not too happy about ad-hoc hardcoding SUN here. Can't we somehow try and find the first registered provider that supports passwordless keystore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@vmuzikar added a guard and updated the comment. In practical terms, we only expect this to be SUN - we only fully support OpenJDKs, and the other common VM implementations have a SUN provider. The only situation that wouldn't work is if the user has disabled the SUN provider and added another provider (other than bc / bcfips). Are you trying to cover that case?

8000
Copilot AI balanced review requested due to automatic review settings October 29, 2026 18:21
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.

🟢 Approval recommended

No active review issues are reported for the change adding a SUN-provider fallback for passwordless PKCS12 truststores.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 19:01
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.

🔵 Needs a closer look

Human assessment is needed because truststore-loading edge cases can silently omit default CA certificates or fail startup despite a valid JRE truststore.

No open issues 🎉

Review effort: Balanced

@shawkins
Copy link
Copy Markdown
Contributor Author

Expanded the changes to incorporate what the other pr was trying to do - make an attempt to load the system truststore with the default password if not provided. The reasoning in the pr description is not valid - all of our supported JREs ship with a cacerts file that is pkcs12. JKS has not been the format for quite some time. However in a fips environment, or as an alternative to the SUN provider, trying to load cacerts with a password may work.

closes: keycloak#54430

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 14:00
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

Critical truststore fallback flaws can still prevent startup with JKS cacerts and silently omit default CA roots from password-protected PKCS12 cacerts, breaking outbound TLS.

2 open issues

Review effort: Balanced

@shawkins
Copy link
Copy Markdown
Contributor Author

To build on the replies to copilot - starting with version 9 openjdk used pkcs12 for cacerts. Then in version 18+ it started using a passwordless pkcs12. Since we still support openjdk 17, it's proper to have the fallback to try the changeit password. All the certs we're interested in are public and are not encrypted - the password (if applicable) is only used in that case for integrity checking.

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 17:59
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.

🟢 Approval recommended

No active review issues block the truststore-loading fallback changes.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@vmuzikar vmuzikar 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.

LGTM, thanks.

@vmuzikar
vmuzikar merged commit ee7e9b1 into keycloak:main Nov 2, 2026
100 checks passed
ruchikajha95 pushed a commit to ruchikajha95/keycloak that referenced this pull request Nov 3, 2026
…#54394)

* fix: allowing cacerts and passwordless pkcs12 in non-strict

closes: keycloak#54430

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* updating the attempts to load the cacerts as well

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* improving naming

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

---------

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TruststoreBuilder does not work in non-strict mode

4 participants

0