Skip to content

Create QuicSslEngine for client with parameter peer host to meet HostnameChecker matching rules - #16200

Merged
EarthChen merged 3 commits into
apache:3.3from
zrlw:3.3-quic-hostnamechecker-enabled
Nov 18, 2026
Merged

EarthChen merged 3 commits into
apache:3.3from
zrlw:3.3-quic-hostnamechecker-enabled

Conversation

@zrlw

@zrlw zrlw commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

What is the purpose of the change?

  1. Since Netty 4.2.11.Final, hostname checker was enabled by default, the checker will get expected hostname from the session created by client QuicSslEngine, but current dubbo created client QuicSslEngine without parameter peerhost and the CertificateException will be thrown at sun.security.util.HostnameChecker#match due to null expectedName ,
    public void match(String expectedName, X509Certificate cert,
                      boolean chainsToPublicCA) throws CertificateException {
        if (expectedName == null) {
            throw new CertificateException("Hostname or IP address is " +
                    "undefined.");
        }
        if (isIpAddress(expectedName)) {
           matchIP(expectedName, cert);
        } else {
           matchDNS(expectedName, cert, chainsToPublicCA);
        }
    }

so we should create QuicSslEngine for client with parameter peer host to support hostname checker.

  1. The server.pem of TripleHttp3ProtocolTest was changed by adding SAN (set ip address to 127.0.0.1) configuration to meet HostnameChecker matching rules.

Checklist

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

@zrlw zrlw changed the title Create QuicSslEngine for client with parameter peer host to support hostname checker Create QuicSslEngine for client with parameter peer host to meethostname checker Apr 9, 2026
@zrlw zrlw changed the title Create QuicSslEngine for client with parameter peer host to meethostname checker Create QuicSslEngine for client with parameter peer host to meet hostname checker requirements Apr 9, 2026
@codecov-commenter

codecov-commenter commented Apr 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.78%. Comparing base (68a16cb) to head (eaa09f8).
⚠️ Report is 107 commits behind head on 3.3.

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16200      +/-   ##
============================================
- Coverage     60.79%   60.78%   -0.02%     
- Complexity    11766    11772       +6     
============================================
  Files          1953     1953              
  Lines         89182    89183       +1     
  Branches      13453    13453              
============================================
- Hits          54219    54209      -10     
- Misses        29395    29402       +7     
- Partials       5568     5572       +4     
Flag Coverage Δ
integration-tests-java21 32.12% <0.00%> (-0.06%) ⬇️
integration-tests-java8 32.25% <0.00%> (-0.04%) ⬇️
samples-tests-java21 32.16% <100.00%> (+0.01%) ⬆️
samples-tests-java8 29.79% <0.00%> (+0.02%) ⬆️
unit-tests-java11 59.01% <100.00%> (-0.02%) ⬇️
unit-tests-java17 58.50% <100.00%> (-0.02%) ⬇️
unit-tests-java21 58.53% <100.00%> (-0.01%) ⬇️
unit-tests-java25 58.47% <100.00%> (-0.03%) ⬇️
unit-tests-java8 59.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Pull request overview

This PR updates Dubbo’s HTTP/3 (QUIC) TLS setup to satisfy Netty’s default hostname verification by ensuring the client-side QUIC SSLEngine is created with a peer host, and refreshes the test server certificate to include a SAN for 127.0.0.1.

Changes:

  • Create the client QUIC SSLEngine with (peerHost, peerPort) via sslEngineProvider(...) to support hostname verification.
  • Stop explicitly disabling endpoint identification in the HTTP/3 client SSL context builder.
  • Update the HTTP/3 test server certificate (server.pem) to include SAN IP:127.0.0.1.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
dubbo-rpc/dubbo-rpc-triple/src/test/resources/certs/server.pem Updates test server certificate to meet hostname verification (SAN) requirements.
dubbo-remoting/dubbo-remoting-http3/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyHttp3ConnectionClient.java Creates QUIC SSLEngine with peer host/port via sslEngineProvider.
dubbo-remoting/dubbo-remoting-http3/src/main/java/org/apache/dubbo/remoting/http3/Http3SslContexts.java Removes explicit disabling of endpoint identification algorithm for client QUIC SSL context.

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

Comment on lines +68 to 72
URL url = getUrl();
QuicSslContext quicSslContext = Http3SslContexts.buildClientSslContext(url);
io.netty.channel.ChannelHandler codec = Http3Helper.configCodec(Http3.newQuicClientCodecBuilder(), getUrl())
.sslContext(Http3SslContexts.buildClientSslContext(getUrl()))
.sslEngineProvider(q -> quicSslContext.newEngine(q.alloc(), url.getHost(), url.getPort()))
.build();

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

The hostname passed to the QUIC SSLEngine is taken from url.getHost()/getPort(), but the actual remote endpoint is getConnectAddress() (which applies NetUtils.filterLocalHost(...) in AbstractClient#getConnectAddress). These can diverge for values like 127.x, 0.0.0.0, or localhost, causing hostname verification to validate against a different name than the one actually connected to (false failures or, worse, validating the wrong peer). Consider using the host/port from getConnectAddress() (or applying the same filterLocalHost logic) when creating the engine.

Copilot uses AI. Check for mistakes.
@zrlw
zrlw requested review from EarthChen, RainYuY and oxsean April 13, 2026 02:25
@zrlw

zrlw commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

@RainYuY

@zrlw zrlw changed the title Create QuicSslEngine for client with parameter peer host to meet hostname checker requirements Create QuicSslEngine for client with parameter peer host to meet hostname checker rules Apr 23, 2026
@zrlw zrlw changed the title Create QuicSslEngine for client with parameter peer host to meet hostname checker rules Create QuicSslEngine for client with parameter peer host to meet hostname checking rules Apr 23, 2026
@zrlw zrlw changed the title Create QuicSslEngine for client with parameter peer host to meet hostname checking rules Create QuicSslEngine for client with parameter peer host to meet HostnameChecker matching rules Apr 23, 2026

@EarthChen EarthChen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified in a local worktree (macOS, JDK 11, Netty 4.2.12.Final at the merge base):

  • Base (68a16cb): TripleHttp3ProtocolTest passes. Since endpointIdentificationAlgorithm(null) was added in #16196, endpoint identification is disabled for client QUIC contexts, so the CertificateException: Hostname or IP address is undefined in the description does not reproduce on the current base. What actually regressed in #16196 is that hostname verification was silently turned off for all HTTP/3 QUIC clients (it was a CI workaround for the test cert lacking a SAN).
  • PR head (eaa09f8): TripleHttp3ProtocolTest passes with the updated server.pem (SAN IP:127.0.0.1).
  • PR head with the old server.pem (no SAN): fails with error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED, which confirms the client now actually verifies the peer identity instead of skipping it.

The fix is correct: QuicheQuicSslContext.newEngine(alloc, peerHost, peerPort) carries the peer host into the engine (and enables SNI for real hostnames), and the builder default (HTTPS for client contexts since Netty 4.2.11.Final) is no longer overridden with null. Users who configured certs get hostname verification back; the no-cert path still uses InsecureTrustManagerFactory, so it is unchanged.

Two notes:

  1. The description says the current code throws CertificateException at sun.security.util.HostnameChecker#match — that only happens when endpoint identification is enabled while the engine has no peer host, not with the current endpointIdentificationAlgorithm(null) state. It would help to reword the motivation as "restore hostname verification that was disabled as a workaround in #16196".
  2. The TCP client has the mirror-image problem on Netty 4.2: SslClientTlsHandler creates the engine with newEngine(alloc) and ssl/SslContexts does not disable endpoint identification, so TCP TLS handshakes fail with "Hostname or IP address is undefined" (tracked in #16589). A follow-up is needed there.

@EarthChen
EarthChen merged commit 7c4a075 into apache:3.3 Nov 18, 2026
94 of 96 checks passed
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.

4 participants