src/java.net.http/share/classes/jdk/internal/net/http/AbstractAsyncSSLConnection.java
branchhttp-client-branch
changeset 56126 86e628130926
parent 56092 fd85b2bf2b0d
child 56137 dd867826d55b
--- a/src/java.net.http/share/classes/jdk/internal/net/http/AbstractAsyncSSLConnection.java	Tue Feb 13 16:22:49 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/AbstractAsyncSSLConnection.java	Wed Feb 14 16:04:18 2018 +0000
@@ -69,14 +69,14 @@
 
     AbstractAsyncSSLConnection(InetSocketAddress addr,
                                HttpClientImpl client,
-                               String serverName,
+                               String serverName, int port,
                                String[] alpn) {
         super(addr, client);
         this.serverName = serverName;
         SSLContext context = client.theSSLContext();
         sslParameters = createSSLParameters(client, serverName, alpn);
         Log.logParams(sslParameters);
-        engine = createEngine(context, sslParameters);
+        engine = createEngine(context, serverName, port, sslParameters);
     }
 
     abstract HttpConnection plainConnection();
@@ -94,6 +94,7 @@
                                                      String[] alpn) {
         SSLParameters sslp = client.sslParameters();
         SSLParameters sslParameters = Utils.copySSLParameters(sslp);
+        sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
         if (alpn != null) {
             Log.logSSL("AbstractAsyncSSLConnection: Setting application protocols: {0}",
                        Arrays.toString(alpn));
@@ -107,9 +108,9 @@
         return sslParameters;
     }
 
-    private static SSLEngine createEngine(SSLContext context,
+    private static SSLEngine createEngine(SSLContext context, String serverName, int port,
                                           SSLParameters sslParameters) {
-        SSLEngine engine = context.createSSLEngine();
+        SSLEngine engine = context.createSSLEngine(serverName, port);
         engine.setUseClientMode(true);
         engine.setSSLParameters(sslParameters);
         return engine;