HttpGet的SSL问题可能是因为服务器正在请求客户端身份验证

时间:2013-07-17 14:22:43

标签: java ssl httpclient ssl-certificate http-get

我们正在使用以下版本的差异库

Apache-HttpComponents-HttpCore = 4.1;
Apache-HttpComponents-HttpClient = 4.1.1;
JDK                            = 1.6_64;

突然开始面对SSLPeerUnverifiedException(HTTP Get failing for HTTPS with javax.net.ssl.SSLPeerUnverifiedException了解详情)。

我尝试了不同的东西,但我不知道为什么即使在接受所有证书之后我们也无法连接到https://www.google.com(尽管如评论中所述,它可能会导致中间人攻击)。 / p>

Google是否开始期待来自客户的证书?如果是,我们该怎么做?

谢谢,

1 个答案:

答案 0 :(得分:0)

  

Google是否开始期待来自客户的证书?如果是,我们该怎么做?

如果我理解你的权利并且谷歌确实需要证书,你应该使用cryptoprovider并通过stunnel进行签名。

你的代码可能有问题吗?此设置适用于我

public HttpClient getNewHttpClient() {
    try {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);

        SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));

        ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);

        return new DefaultHttpClient(ccm, params);
    } catch (Exception e) {
        return new DefaultHttpClient();
    }
}