Skip to content

[KNET-21308] Capture SNI via SNIMatcher instead of ExtendedSSLSession#703

Draft
Truc Nguyen (trnguyencflt) wants to merge 2 commits into
masterfrom
snimatcher-insteadof-sslsession
Draft

[KNET-21308] Capture SNI via SNIMatcher instead of ExtendedSSLSession#703
Truc Nguyen (trnguyencflt) wants to merge 2 commits into
masterfrom
snimatcher-insteadof-sslsession

Conversation

@trnguyencflt
Copy link
Copy Markdown
Member

@trnguyencflt Truc Nguyen (trnguyencflt) commented May 20, 2026

KNET-21308

Summary

  • Install a per-SSLEngine CapturingSniMatcher from SslFactory.customize(), only when no SNI_HOST_NAME matcher is already configured (Jetty installs its own AliasSNIMatcher whenever the keystore has hostname-bearing certs, used by SniX509ExtendedKeyManager for SNI-based cert selection — we coexist with it rather than trample it).
  • SniUtils.getSniServerName() reads from CapturingSniMatcher when present; otherwise falls back to ExtendedSSLSession.getRequestedServerNames(), which is reliably populated because Jetty's AliasSNIMatcher ran.
  • Covers the case where no SNI matcher would otherwise be configured (e.g. SPIFFE/SPIRE setups with no Java keystore), where getRequestedServerNames() is not populated server-side on some JSSE providers.
  • No client-visible behavior change: matcher always returns true, so policy checks remain in the existing SniHandler / PrefixSniHandler / ExpectedSniHandler.

Test plan

  • mvn -pl core compile
  • mvn -pl core failsafe:integration-test -Dit.test='SniHandlerIntegrationTest,PrefixSniHandlerIntegrationTest,ExpectedSniHandlerIntegrationTest' — 52/52 pass
  • mvn -pl core test -Dtest=ExpectedSniHandlerTest — 7/7 pass

Install a CapturingSniMatcher per SSLEngine in SslFactory's customize()
and read the captured name from SSLParameters.getSNIMatchers() in
SniUtils. Replaces the server-side ExtendedSSLSession.getRequestedServerNames()
lookup, which is not reliably populated on the server side by all JSSE
providers (notably FIPS providers). No behavior change for clients: the
matcher always returns true, so policy checks remain in the existing
HTTP-level SniHandler / PrefixSniHandler / ExpectedSniHandler.
Copilot AI review requested due to automatic review settings May 20, 2026 13:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR changes how the server extracts the client-provided SNI host name by installing a per-SSLEngine SNIMatcher that captures the SNI during the TLS handshake, instead of relying on ExtendedSSLSession.getRequestedServerNames() (which may be unpopulated in some JSSE/FIPS providers).

Changes:

  • Install a per-connection CapturingSniMatcher via SslContextFactory.Server.customize(SSLEngine).
  • Update SniUtils to read the captured SNI value from the installed matcher rather than ExtendedSSLSession.
  • Add CapturingSniMatcher implementation to record the SNI host name during handshake.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
core/src/main/java/io/confluent/rest/SslFactory.java Installs a per-SSLEngine SNI matcher during Jetty SSL engine customization.
core/src/main/java/io/confluent/rest/handlers/SniUtils.java Switches SNI extraction logic to read from the capturing matcher.
core/src/main/java/io/confluent/rest/handlers/CapturingSniMatcher.java New matcher that captures the SNI host name while always allowing the handshake to proceed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/main/java/io/confluent/rest/SslFactory.java Outdated
@trnguyencflt Truc Nguyen (trnguyencflt) changed the title Capture SNI via SNIMatcher instead of ExtendedSSLSession [KNET-21308] Capture SNI via SNIMatcher instead of ExtendedSSLSession May 20, 2026
Only install CapturingSniMatcher when no SNI_HOST_NAME matcher is
already configured by Jetty (it installs AliasSNIMatcher whenever the
keystore has hostname-bearing certs, used by SniX509ExtendedKeyManager
for cert selection). When Jetty's matcher is present, SniUtils falls
back to ExtendedSSLSession.getRequestedServerNames(), which is reliably
populated because AliasSNIMatcher ran.

Addresses PR #703 review feedback.
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.

2 participants