referenced this link
http://theskeleton.wordpress.com/2010/07/24/avoiding-the-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated-with-httpclient/
The following class takes a HttpClient and returns a new HttpClient that accepts any SSL certificate:
01public class WebClientDevWrapper {
02
03 public static HttpClient wrapClient(HttpClient base) {
04 try {
05 SSLContext ctx = SSLContext.getInstance("TLS");
06 X509TrustManager tm = new X509TrustManager() {
07
08 public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException {
09 }
10
11 public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {
12 }
13
14 public X509Certificate[] getAcceptedIssuers() {
15 return null;
16 }
17 };
18 ctx.init(null, new TrustManager[]{tm}, null);
19 SSLSocketFactory ssf = new SSLSocketFactory(ctx);
20 ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
21 ClientConnectionManager ccm = base.getConnectionManager();
22 SchemeRegistry sr = ccm.getSchemeRegistry();
23 sr.register(new Scheme("https", ssf, 443));
24 return new DefaultHttpClient(ccm, base.getParams());
25 } catch (Exception ex) {
26 ex.printStackTrace();
27 return null;
28 }
29 }
30}
You can then do something like this in the code that creates the HttpClient:
1this.client = new DefaultHttpClient();
2if(dev) {
3 this.client = WebClientDevWrapper.wrapClient(client);
4}
referenced this link
http://theskeleton.wordpress.com/2010/07/24/avoiding-the-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated-with-httpclient/