Merge "Try to set endpoint identification algorithm if available"
diff --git a/android/main/java/com/squareup/okhttp/internal/Platform.java b/android/main/java/com/squareup/okhttp/internal/Platform.java
index f4828f2..d93d16a 100644
--- a/android/main/java/com/squareup/okhttp/internal/Platform.java
+++ b/android/main/java/com/squareup/okhttp/internal/Platform.java
@@ -28,6 +28,7 @@
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLParameters;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.X509TrustManager;
 
@@ -86,6 +87,10 @@
     /** setAlpnSelectedProtocol(byte[]) */
     private static final OptionalMethod<Socket> SET_ALPN_PROTOCOLS =
             new OptionalMethod<Socket>(null, "setAlpnProtocols", byte[].class );
+    /** setEndpointIdentificationAlgorithm(String) */
+    private static final OptionalMethod<SSLParameters> SET_ENDPOINT_IDENTIFICATION_ALGORITHM =
+            new OptionalMethod<SSLParameters>(null, "setEndpointIdentificationAlgorithm",
+                    String.class);
 
     public void logW(String warning) {
         System.logW(warning);
@@ -101,10 +106,14 @@
 
     public void configureTlsExtensions(
             SSLSocket sslSocket, String hostname, List<Protocol> protocols) {
-        // Enable SNI and session tickets.
+        // Enable SNI, session tickets, and endpoint identification algorithm.
         if (hostname != null) {
             SET_USE_SESSION_TICKETS.invokeOptionalWithoutCheckedException(sslSocket, true);
             SET_HOSTNAME.invokeOptionalWithoutCheckedException(sslSocket, hostname);
+
+            // Set endpoint hostname identification algorithm.
+            SET_ENDPOINT_IDENTIFICATION_ALGORITHM.invokeWithoutCheckedException(
+                    sslSocket.getSSLParameters(), "HTTPS");
         }
 
         // Enable ALPN.