Use InetAddress.getHostString() in WolfSSLSocket.connect() to keep original hostname#374
Open
cconlon wants to merge 1 commit into
Open
Use InetAddress.getHostString() in WolfSSLSocket.connect() to keep original hostname#374cconlon wants to merge 1 commit into
cconlon wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes WolfSSLSocket.connect(SocketAddress) so that SNI and HTTPS endpoint identification use the application-supplied hostname (instead of the resolved IP), aligning behavior with SunJSSE for the createSocket() + connect(InetSocketAddress) flow.
Changes:
- Update
WolfSSLSocket.connect()to store the peer host viaInetSocketAddress.getHostString()(preserves the original hostname without reverse DNS). - Add a new regression test covering multiple
InetSocketAddressconstruction paths and assertingSSLSession.getPeerHost()behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/java/com/wolfssl/provider/jsse/WolfSSLSocket.java |
Preserves original hostname for SNI/endpoint identification by using InetSocketAddress.getHostString() when registering host/port after connect(). |
src/test/com/wolfssl/provider/jsse/test/WolfSSLSocketTest.java |
Adds coverage for createSocket() + connect(InetSocketAddress) ensuring SSLSession.getPeerHost() matches SunJSSE-style derivation rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…eep original hostname
8b5e5e9 to
ffcf18e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes SNI and HTTPS endpoint identification for the
createSocket()+connect(InetSocketAddress)flow.WolfSSLSocket.connect(SocketAddress)stored the resolved IP as the peer host instead of the original hostname, so hostname verification ran against the IP and failed against certs with DNS SANs.This PR uses
InetSocketAddress.getHostString()instead ofgetAddress().getHostAddress(), which preserves the application-supplied hostname (no reverse DNS lookup).Adds
testConnectSocketAddressPreservesHostname, covering all three paths and assertingSSLSession.getPeerHost()as follows:new InetSocketAddress("localhost", p)localhostnew InetSocketAddress(getByName("localhost"), p)localhostnew InetSocketAddress(getByAddress(bytes), p)127.0.0.1ZD 22051