8369950: TLS connection to IPv6 address fails with BCJSSE due to IllegalArgumentException #1
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.
Hi all,
Let me propose a fix and a test case for JDK-8369950.
The failure reproduces with BCJSSE provider and all implementations of SSLSocker other than SSLSocketImpl.
In the test case an anonymous wrapper is used, over the standard SSLSocketImpl, to simulate an external JSSE provider. The test case shows the same behavior as in BCJSSE case (failure due to non-LDH ASCII characters in the SNI host name).
The fix avoids constructing SNIHostName when the URL host name is an IPv4 or IPv6 literal address. Other than that, all other FQDN host names that have invalid characters (non-LDH ASCII characters) still produce that exception.
SNIHostName, as defined in
jdk/src/java.base/share/classes/javax/net/ssl/SNIHostName.java
Lines 44 to 66 in 873f8a6
has the fully qualified DNS hostname of the server. As follows from the section 3, "Server Name Indication", RFC 6066,
Literal IPv4 and IPv6 addresses are not permitted in "HostName".This mirrors the behavior of SSLSocketImpl, that avoids constructing the SNIHostName from literal addresses. Please see
jdk/src/java.base/share/classes/sun/security/ssl/Utilities.java
Lines 110 to 116 in 873f8a6
Testing:
BCJSSE standard
BCJSSE FIPS