class ProviderHostnameVerifier implements HostnameVerifier {

    @Override
    public boolean verify(String hostname, SSLSession session) {

        Certificate[] certs = null;
        try {
            certs = session.getPeerCertificates();
        } catch (SSLPeerUnverifiedException ignored) {
        }
        if (certs == null) {
            return false;
        }
        
        for (Certificate cert : certs) {
            final X509Certificate x509Cert = (X509Certificate) cert;
            if (serviceName.equals(Crypto.extractX509CertCommonName(x509Cert))) {
                return true;
            }
        }
        return false;
    }

    public  ProviderHostnameVerifier(String serviceName);

}