Skip to content

Pass the peer address to the TCP TLS client engine - #16590

Merged
EarthChen merged 6 commits into
apache:3.3from
wozhenbang2004:fix/tcp-tls-peer-host
Nov 20, 2026
Merged

EarthChen merged 6 commits into
apache:3.3from
wozhenbang2004:fix/tcp-tls-peer-host

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

What is the purpose of the change?

Fixes #16589.

Pass the connection address to the client TLS engine. This lets Netty’s default hostname verification check the server certificate instead of failing with an undefined peer host.

Add real TLS handshake regressions for both TCP clients, covering matching and mismatched SANs. The related QUIC change is #16200.

Checks: 6 targeted tests pass; module Checkstyle and Spotless pass.

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?

@codecov-commenter

codecov-commenter commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.17%. Comparing base (7c4a075) to head (a8dcd53).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16590      +/-   ##
============================================
+ Coverage     61.15%   61.17%   +0.01%     
+ Complexity    11768       15   -11753     
============================================
  Files          1953     1953              
  Lines         89354    89359       +5     
  Branches      13487    13487              
============================================
+ Hits          54646    54666      +20     
+ Misses        29088    29070      -18     
- Partials       5620     5623       +3     
Flag Coverage Δ
integration-tests-java21 32.09% <0.00%> (-0.01%) ⬇️
integration-tests-java8 32.32% <0.00%> (+0.10%) ⬆️
samples-tests-java21 32.10% <0.00%> (+<0.01%) ⬆️
samples-tests-java8 29.69% <0.00%> (+0.06%) ⬆️
unit-tests-java11 59.47% <100.00%> (+0.07%) ⬆️
unit-tests-java17 58.88% <100.00%> (+0.04%) ⬆️
unit-tests-java21 58.89% <100.00%> (+0.02%) ⬆️
unit-tests-java25 58.89% <100.00%> (+0.08%) ⬆️
unit-tests-java8 59.45% <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.

@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 on 3.3 @ 7c4a075 (which already includes #16200): the TCP path still
creates the client SSLEngine without a peer host, so a trusted certificate with
a matching SAN fails the handshake. Running this PR's regression test on that
base commit gives 2 failures (acceptsMatchingSubjectAlternativeName, both
NettyClient and NettyConnectionClient, SSLHandshakeException: certificate_unknown);
with the PR applied all 4 tests pass. #16200 only fixed the QUIC/HTTP3 engine,
so this fix for the TCP clients is still needed.

The fix matches the approach merged in #16200 (pass the peer host at engine
creation) and I found no other uncovered newEngine call sites. Minor notes,
non-blocking: the rejectsMismatched cases on the unpatched base also "pass" but
for the wrong reason (undefined peer host rather than SAN mismatch), and the
legacy SslClientTlsHandler(URL) constructor path is not covered by the new
test. Also consider rebasing onto the current 3.3 tip before merge.

Assert the peer host and port and inspect the client's handshake failure for a certificate SAN mismatch. Delay the server handshake until the client handler has been captured, so a failed handshake cannot race with channel lookup.

Add coverage for the URL and context-only SslClientTlsHandler constructors.

Fixes apache#16589
@EarthChen
EarthChen merged commit d809bb1 into apache:3.3 Nov 20, 2026
32 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.

[Bug] TCP TLS handshakes fail because the peer hostname is missing

3 participants