Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.StringTokenizer;

import javax.net.ssl.*;
import sun.net.util.IPAddressUtil;
import sun.net.www.http.HttpClient;
import sun.net.www.protocol.http.AuthCacheImpl;
import sun.net.www.protocol.http.HttpURLConnection;
Expand Down Expand Up @@ -471,7 +472,13 @@ public void afterConnect() throws IOException, UnknownHostException {
SSLParameters parameters = s.getSSLParameters();
parameters.setEndpointIdentificationAlgorithm("HTTPS");
// host has been set previously for SSLSocketImpl
if (!(s instanceof SSLSocketImpl)) {
if (!(s instanceof SSLSocketImpl) &&
!IPAddressUtil.isIPv4LiteralAddress(host) &&
!(host.charAt(0) == '[' && host.charAt(host.length() - 1) == ']' &&
IPAddressUtil.isIPv6LiteralAddress(host.substring(1, host.length() - 1))
)) {
// Fully qualified DNS hostname of the server, as per section 3, RFC 6066
// Literal IPv4 and IPv6 addresses are not permitted in "HostName".
parameters.setServerNames(List.of(new SNIHostName(host)));
}
s.setSSLParameters(parameters);
Expand Down
Loading
Loading