Code example for SSLSession

Methods: getPeerHost

0
  public void modify(ClientConfig clientConfig) {
 
    HostnameVerifier hv = new HostnameVerifier() {
      public boolean verify(String urlHostName, SSLSession session) {
        // Write a warning, as there is certainly a potential security implication here. 
        System.out.println(String.format("Warning:  URL Host: '%s' does not equal '%s'", urlHostName, session.getPeerHost()));
        return true; 
      } 
    }; 
 
    TrustManager[] trustAll = new TrustManager[] {
        new X509TrustManager() {
          public X509Certificate[] getAcceptedIssuers() {
            return new X509Certificate[] {};
          } 
 
          public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
 
          public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
        } 
Contextual code suggestions in your IDE  Get Codota for Java