diff options
author | Kenny Root <kroot@google.com> | 2015-05-12 15:13:50 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2015-05-13 13:04:44 -0700 |
commit | 725a4a71b8f2a5493628d87556c78860f66d2308 (patch) | |
tree | 960893e8409ac62b0ba7bfbd97cd31eaef2bd3a4 /core/java/org/apache | |
parent | 80283cd747d247780a5336bad6b41811175fd282 (diff) | |
download | frameworks_base-725a4a71b8f2a5493628d87556c78860f66d2308.zip frameworks_base-725a4a71b8f2a5493628d87556c78860f66d2308.tar.gz frameworks_base-725a4a71b8f2a5493628d87556c78860f66d2308.tar.bz2 |
Start handshake before calling hostname verifier, part 2
If the hostname verifier calls SSLSocket#getSession() before the
handshake has been started, it will implicitly start the handshake.
However, it will swallow any errors and return the canonical invalid
SSLSession instead. This makes it extremely difficult to debug issues.
Instead start the handshake before calling into the verifier since we
are guaranteed to be the first caller of #startHandshake() and won't
cause a renegotiation. That will allow us to see the actual
SSLHandshakeException if it occurs.
Follow up for change 317c0a4959df0361431d5fbf7dacc162bfb48cd2
Bug: 21118659
Change-Id: I8c606a78ba8a990b4e0d28880b566867261fefbc
Diffstat (limited to 'core/java/org/apache')
-rw-r--r-- | core/java/org/apache/http/conn/ssl/SSLSocketFactory.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java b/core/java/org/apache/http/conn/ssl/SSLSocketFactory.java index ae14149..250932b 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; |