hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ahmed Ashour <asash...@yahoo.com>
Subject Some websites: SSLPeerUnverifiedException: peer not authenticated
Date Tue, 06 Sep 2011 08:56:29 GMT
Dear all,

I know this is a common question, but the below answer doesn't work for all the websites (e.g.
https://tradingpartners.comcast.com/PortOut/)

On trying to specify custom TrustMangaer, it works for many websites, but not all.

The below code gives "javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated"

Appreciate your help.

-------------------------------------------------
            HttpClient client = new DefaultHttpClient();
            final SSLContext sslContext = SSLContext.getInstance("SSL");
            sslContext.init(null, new TrustManager[] {new X509TrustManager(){

                public void checkClientTrusted(X509Certificate[] arg0,
                        String arg1) throws CertificateException {
                }

                public void checkServerTrusted(X509Certificate[] arg0,
                        String arg1) throws CertificateException {
                }

                public X509Certificate[] getAcceptedIssuers() {
                    return new X509Certificate[0];
                }
                
            }}, null);
            final SSLSocketFactory factory = new SSLSocketFactory(sslContext, new
AllowAllHostnameVerifier());
            final Scheme https = new Scheme("https", 443, factory);

            final SchemeRegistry schemeRegistry = client.getConnectionManager().getSchemeRegistry();
            schemeRegistry.register(https);

            HttpGet get = new HttpGet("https://tradingpartners.comcast.com/PortOut/");
            client.execute(get);
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message