private static SSLSession getHandshakeSessionOrThrow(SSLSocket sslSocket)
            throws CertificateException {
        SSLSession session = sslSocket.getHandshakeSession();
        if (session == null) {
            throw new CertificateException("Not in handshake; no session available");
        }
        return session;
    }
For backward compatibility with older Android API that used String for the hostname only.
common/src/main/java/org/conscrypt/TrustManagerImpl.java