Skip to content

Make Chrome trust the test framework managed TLS certificate - #54092

Open
trixpan wants to merge 1 commit into
keycloak:mainfrom
trixpan:issue-chrome-trust-managed-tls
Open

trixpan wants to merge 1 commit into
keycloak:mainfrom
trixpan:issue-chrome-trust-managed-tls

Conversation

@trixpan

@trixpan trixpan commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Closes #54091

Summary

  • Expose the SHA-256 SPKI hash of the TLS certificate generated by ManagedCertificates.
  • Supply that exact SPKI to Chrome and Chrome Headless through --ignore-certificate-errors-spki-list.
  • Wire managed certificates into both Chrome WebDriver suppliers so TLS-enabled tests receive authenticated secure-context behavior.

Testing

  • Add coverage proving the exported SPKI matches the certificate presented by the managed HTTPS server.
  • Add Chrome options coverage for TLS-enabled and TLS-disabled managed-certificate configurations.

This keeps trust scoped to the generated test certificate and does not modify the host trust store.

@trixpan
trixpan requested a review from a team as a code owner October 19, 2026 01:12
Copilot AI balanced review requested due to automatic review settings October 19, 2026 01:12

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

Headless Chrome retains the broad certificate-error bypass, so trust is not restricted to the managed key.

1 open issue
What changed in this PR

Adds managed-certificate SPKI configuration to Chrome WebDriver sessions, addressing #54091 without modifying host trust stores.

Changes:

  • Exposes the managed server certificate’s SHA-256 SPKI hash.
  • Passes the hash to Chrome and Chrome Headless.
  • Adds certificate-hash and Chrome-options tests.
File Description
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​DriverUtils.java Builds and applies TLS arguments.
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​ChromeWebDriverSupplier.java Injects managed certificates into Chrome setup.
test-framework/​ui/​src/​main/​java/​org/​keycloak/​testframework/​ui/​webdriver/​ChromeHeadlessWebDriverSupplier.java Injects managed certificates into headless setup.
test-framework/​tests/​src/​test/​java/​org/​keycloak/​testframework/​ui/​webdriver/​DriverOptionsTest.java Tests TLS-dependent Chrome arguments.
test-framework/​tests/​src/​test/​java/​org/​keycloak/​testframework/​tests/​TlsEnabledTest.java Checks the hash against the HTTPS certificate.
test-framework/​core/​src/​main/​java/​org/​keycloak/​testframework/​https/​ManagedCertificates.java Exports the server certificate’s SPKI hash.

Review effort: Balanced

Comment on lines +39 to +40
ChromeOptions options = DriverOptions.createChromeOptions(headless);
options.addArguments(extraArguments);

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.

Fixed in dceef13. Headless Chrome no longer receives the broad --ignore-certificate-errors bypass; managed TLS now relies only on the certificate-scoped SPKI exception. DriverOptionsTest also asserts that the broad bypass is absent. Verified with ./mvnw -o -pl test-framework/tests -Dtest=DriverOptionsTest test (2 tests, 0 failures).

@trixpan
trixpan force-pushed the issue-chrome-trust-managed-tls branch from db1c440 to dceef13 Compare October 19, 2026 01:24
Copilot AI balanced review requested due to automatic review settings October 19, 2026 01: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

No concrete defects were identified, but authenticated TLS and DBSC behavior still require browser-level validation.

1 open issue

Review effort: Balanced

@trixpan
trixpan force-pushed the issue-chrome-trust-managed-tls branch from dceef13 to 40cf5e6 Compare October 19, 2026 02:16
Copilot AI balanced review requested due to automatic review settings October 19, 2026 02:16

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

Certificate hashing, Chrome dependency wiring, and regression coverage are consistent, with no unresolved blocking issues.

1 open issue

Review effort: Balanced

Chrome treated the managed self-signed server certificate as an error
(--ignore-certificate-errors), so pages served over the TLS test server
were not secure contexts and secure-context-only features were disabled.
Pin the managed server certificate via --ignore-certificate-errors-spki-list,
matching the leaf-trust model the managed Java clients already use.

Closes keycloak#54091

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andre F de Miranda <trixpan@users.noreply.github.com>
@trixpan
trixpan force-pushed the issue-chrome-trust-managed-tls branch from 40cf5e6 to 4406b5d Compare November 26, 2026 23:01
Copilot AI balanced review requested due to automatic review settings November 26, 2026 23: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

Real Chromium 152+ validation is needed because existing tests cover SPKI and command-line options but do not establish that the scoped exception preserves authenticated TLS state and enables DBSC header processing.

1 open issue

Review effort: Balanced

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.

Chrome WebDriver should trust the test framework managed TLS certificate

3 participants