diff --git a/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java b/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java index ae14149987cf0..250932be0f365 100644 --- a/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java +++ b/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java @@ -397,6 +397,14 @@ public class SSLSocketFactory implements LayeredSocketFactory { port, autoClose ); + // BEGIN android-added + /* + * Make sure we have started the handshake before verifying. + * Otherwise when we go to the hostname verifier, it directly calls + * SSLSocket#getSession() which swallows SSL handshake errors. + */ + sslSocket.startHandshake(); + // END android-added hostnameVerifier.verify(host, sslSocket); // verifyHostName() didn't blowup - good! return sslSocket;