title: Exception : javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
body: <pre><code>public HttpClientVM() {
  
      BasicHttpParams params = new BasicHttpParams();
      ConnManagerParams.setMaxTotalConnections(params, 10);
      HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
      HttpProtocolParams.setUseExpectContinue(params, false);
      HttpConnectionParams.setStaleCheckingEnabled(params, true);
      HttpConnectionParams.setConnectionTimeout(params, 30000);
      HostnameVerifier hostnameVerifier=
            org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
      HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
      SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
      socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
      SchemeRegistry schemeRegistry = new SchemeRegistry();
      schemeRegistry.register(new Scheme("http",socketFactory, 80));
      schemeRegistry.register(new Scheme("https",socketFactory, 443));
          ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params, schemeRegistry);
          // Set verifier     
          client = new DefaultHttpClient(manager, params);    
      }
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>When executing <code>client.accessURL(url)</code>, the following error occurs:</p>
  
  <pre><code>Exception in thread "main" javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
      at com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)
      at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
      at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397)
      at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:495)
      at org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:62)
      at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
      at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:150)
      at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
      at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:575)
      at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
  </code></pre>
  
  <p><strong><em>Additional information:</em></strong></p>
  
  <ul>
  <li>Window 7</li>
  <li>HttpClient 4</li>
  </ul>