views:

557

answers:

2

Using HttpClient, I receive the following error when attempting to communicate over HTTPS:

Exception in thread "main" javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated.

URI loginUri = new URI("https://myUrl.asp");

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet( loginUri );
HttpResponse response = httpclient.execute( httpget );

How do I suppress or remove this error?

A: 

Using HttpClient 3.x, you need to do this:

Protocol easyhttps = new Protocol( "https", new EasySSLProtocolScoketFactory(), 443);
Protocol.registerProtocol("https",easyhttps);

An implementation of EasySSLProtocolSocketFactory can be found here.

Stefan Kendall
A: 

I'm using HttpClient 4.xx.

and had the same problem (javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated).

This one solved my prob' :

http://en.wikibooks.org/wiki/Programming:WebObjects/Web_Services/How_to_Trust_Any_SSL_Certificate

Prabu