private void checkIdentity ( SSLSession session , X509Certificate cert ) throws CertificateException { if ( session == null ) { throw new CertificateException ( "No handshake session" ) ; } if ( EndpointIdentificationAlgorithm . HTTPS == identityAlg ) { String hostname = session . getPeerHost ( ) ; APINameChecker . verifyAndThrow ( hostname , cert ) ; } }
check server identify against hostnames . This method is used to enhance X509TrustManager to provide standard identity check .