Repository navigation
Create QuicSslEngine for client with parameter peer host to meet HostnameChecker matching rules - #16200
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
SSLEnginewith(peerHost, peerPort)viasslEngineProvider(...)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 SANIP: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.
| 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(); |
There was a problem hiding this comment.
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.
EarthChen
left a comment
There was a problem hiding this comment.
Verified in a local worktree (macOS, JDK 11, Netty 4.2.12.Final at the merge base):
- Base (68a16cb):
TripleHttp3ProtocolTestpasses. SinceendpointIdentificationAlgorithm(null)was added in #16196, endpoint identification is disabled for client QUIC contexts, so theCertificateException: Hostname or IP address is undefinedin 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):
TripleHttp3ProtocolTestpasses with the updatedserver.pem(SAN IP:127.0.0.1). - PR head with the old
server.pem(no SAN): fails witherror: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:
- The description says the current code throws
CertificateExceptionatsun.security.util.HostnameChecker#match— that only happens when endpoint identification is enabled while the engine has no peer host, not with the currentendpointIdentificationAlgorithm(null)state. It would help to reword the motivation as "restore hostname verification that was disabled as a workaround in #16196". - The TCP client has the mirror-image problem on Netty 4.2:
SslClientTlsHandlercreates the engine withnewEngine(alloc)andssl/SslContextsdoes 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.
What is the purpose of the change?
peerhostand the CertificateException will be thrown atsun.security.util.HostnameChecker#matchdue to nullexpectedName,so we should create QuicSslEngine for client with parameter peer host to support hostname checker.
server.pemofTripleHttp3ProtocolTestwas changed by adding SAN (set ip address to 127.0.0.1) configuration to meet HostnameChecker matching rules.Checklist