Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a406787 authored by Kenny Root's avatar Kenny Root
Browse files

Use hostname verifier directly instead of instance

Instead of local instance of the default HostnameVerifier, use it
directly from HttpsURLConnection. This avoids class preloading creating
an instance of it before it's necessary.

(cherry picked from commit 928ee1e4)

Bug: 9984058
Change-Id: I9017256b3b5d137aeb5a6f455868af7bdfec7885
parent 7adc233c
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -81,9 +81,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
        }
    };

    private static final HostnameVerifier HOSTNAME_VERIFIER =
        HttpsURLConnection.getDefaultHostnameVerifier();

    private SSLSocketFactory mInsecureFactory = null;
    private SSLSocketFactory mSecureFactory = null;
    private TrustManager[] mTrustManagers = null;
@@ -196,7 +193,7 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
            if (session == null) {
                throw new SSLException("Cannot verify SSL socket without session");
            }
            if (!HOSTNAME_VERIFIER.verify(hostname, session)) {
            if (!HttpsURLConnection.getDefaultHostnameVerifier().verify(hostname, session)) {
                throw new SSLPeerUnverifiedException("Cannot verify hostname: " + hostname);
            }
        }