簡體   English   中英

HttpGet的SSL問題可能是因為服務器正在請求客戶端身份驗證

[英]SSL issue with HttpGet probably because server is requesting client authentication

我們正在使用以下版本的差異庫

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

然后突然開始面對SSLPeerUnverifiedException( 有關HTTPS的javax.net.ssl.SSLPeerUnverifiedException的HTTP獲取失敗消息 )。

我嘗試了不同的方法,但是我不知道為什么即使接受所有證書后我們仍無法連接到https://www.google.com (盡管如評論中所述,它可能會導致中間攻擊)。

Google可能會開始期望客戶端提供證書嗎? 如果是,該怎么辦?

謝謝,

Google可能會開始期望客戶端提供證書嗎? 如果是,該怎么辦?

如果我理解正確,並且Google確實需要證書,則應使用cryptoprovider並通過通道進行簽名。

也許您的代碼有誤? 此設置對我有用

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();
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM