code: 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);
  		}
  	}
docs: check server identify against hostnames. This method is used to enhance X509TrustManager to provide standard identity check.
  
  This method can be applied to both clients and servers.
  
  @param session
  @param cert
  @throws CertificateException