8000 Trust managed TLS certificates for outbound connections by trixpan · Pull Request #54143 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Trust managed TLS certificates for outbound connections - #54143

Open
trixpan wants to merge 1 commit into
keycloak:mainfrom
trixpan:issue-54140-managed-outbound-trust
Open

trixpan wants to merge 1 commit into
keycloak:mainfrom
trixpan:issue-54140-managed-outbound-trust

Conversation

@trixpan
@trixpan trixpan commented Oct 19, 2026 •
Copy link
Copy Markdown
Contributor

Closes #54140

Summary

  • Export certificates from the managed client truststore as a PEM bundle suitable for truststore-paths.
  • Configure TLS-enabled test servers to trust the managed certificate for outbound HTTPS connections.
  • Merge managed trust paths with paths configured by tests or interceptors into a single truststore-paths list value, including the PEM mTLS truststore.
  • Quote comma-containing arguments when launching kc.bat on Windows, as cmd.exe would otherwise split them.
  • Verify Keycloak's server-side HTTP client can call the managed HTTPS endpoint without disabling certificate validation.
  • Verify the server truststore contains both a test-configured certificate and the managed certificates.
  • Point the non-strict FIPS CI job at the JDK cacerts as JKS. RH OpenJDK ships cacerts as JKS, but merging the default truststore assumes PKCS12, which BCFIPS rejects in non-strict mode once truststore-paths is set (Truststore consolidation broke keycloak fips mode #28526).

The PEM bundle is provider-neutral input to truststore-paths; Keycloak converts it to the active provider's preferred generated truststore format, including BCFKS in strict FIPS mode.

Testing

  • ./mvnw package -f test-framework/pom.xml
  • KC_TEST_SERVER=embedded ./mvnw package -f test-framework/tests/pom.xml -Dtest=CustomConfigTest,RunOnServerTest,TlsEnabledTest
  • ./mvnw spotless:check -pl test-framework/core,test-framework/tests

AI assistance

This PR was developed with assistance from OpenAI Codex. I reviewed and understand the submitted changes.

@trixpan
trixpan requested a review from a team as a code owner October 19, 2026 23:11
Copilot AI balanced review requested due to automatic review settings October 19, 2026 23:11
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

Existing trust paths can be overwritten, and reused servers can retain stale trust anchors after the client truststore changes.

2 open issues
What changed in this PR

Adds outbound TLS trust for framework-managed certificates, addressing #54140 without disabling certificate validation.

Changes:

  • Exports client trust certificates as a provider-neutral PEM bundle.
  • Configures server trust paths alongside inbound mTLS settings.
  • Adds a server-side HTTPS client integration test.
File Description
test-framework/​tests/​src/​test/​java/​org/​keycloak/​testframework/​tests/​TlsEnabledTest.java Tests outbound HTTPS certificate validation.
test-framework/​core/​src/​main/​java/​org/​keycloak/​testframework/​server/​AbstractKeycloakServerSupplier.java Adds managed certificates to server trust configuration.
test-framework/​core/​src/​main/​java/​org/​keycloak/​testframework/​https/​ManagedCertificates.java Exports and exposes the PEM trust bundle.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 20, 2026 02:28
@trixpan
trixpan force-pushed the issue-54140-managed-outbound-trust branch from 5d20611 to beb15a0 Compare October 20, 2026 02:28
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

CLI normalization retains only the last repeated truststore option, discarding earlier trust paths.

1 open issue
2 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 20, 2026 04:24
@trixpan
trixpan force-pushed the issue-54140-managed-outbound-trust branch from beb15a0 to af1903e Compare October 20, 2026 04: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.

🔵 Needs a closer look

Windows batch argument handling still needs platform-specific validation beyond the string-level regression test.

1 open issue

Review effort: Balanced

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.webauthn.passwordless.WebAuthnPwdLessPropertyTest#timeout

Keycloak CI - WebAuthn IT

org.openqa.selenium.WebDriverException: 
unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not belong to the document"}
  (Session info: chrome=155.0.8059.39)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

Copilot AI balanced review requested due to automatic review settings October 20, 2026 12:33
@trixpan
trixpan force-pushed the issue-54140-managed-outbound-trust branch from af1903e to b026f07 Compare October 20, 2026 12:33
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

Windows batch quoting and FIPS truststore compatibility need platform-specific validation before approval.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Export the managed client truststore as a PEM bundle and add it to the server truststore paths when TLS is enabled. Keycloak keeps only the last repeated CLI option, so truststore paths are merged into a single list value that preserves paths configured by tests or interceptors. Comma-containing arguments are quoted when launching kc.bat, as cmd.exe would otherwise split them.

Verify the server-side HTTP client can connect to the managed HTTPS endpoint without disabling certificate validation, and that the server truststore contains both test-configured and managed certificates.

Point the non-strict FIPS job at the JDK cacerts as JKS. RH OpenJDK ships cacerts as JKS, but merging the default truststore assumes PKCS12, which BCFIPS rejects in non-strict mode (keycloak#28526).

Closes keycloak#54140

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Signed-off-by: Andre F de Miranda <trixpan@users.noreply.github.com>
@trixpan
trixpan force-pushed the issue-54140-managed-outbound-trust branch from b026f07 to 0459f23 Compare November 26, 2026 23:02
Copilot AI balanced review requested due to automatic review settings November 26, 2026 23:02
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

Using the merged system truststore for mTLS admits clients signed by outbound-only CAs, unintentionally widening client-certificate authentication.

1 open issue

Review effort: Balanced

null, managedCert.getServerTrustStorePath(), managedCert.getKeystoreFormat().name()))) {
// for PEM file use common truststore paths option
command.option("truststore-paths", managedCert.getServerTrustStorePath());
command.addOption("truststore-paths", managedCert.getServerTrustStorePath());
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.

Configure managed TLS certificates for outbound trust in the test framework

2 participants

0