gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:09 25 4
gpt4 key购买 nike

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

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即使在接受所有证书后(尽管如评论中所述,它可能会导致中间人攻击)。

Google 是否开始要求客户提供证书?如果是,我们应该怎么做?

谢谢,

最佳答案

Could it be the case that Google started expecting certificate from the client? If yes, what should we do?

如果我理解你是对的并且谷歌确实需要证书,你应该使用 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();
}
}

关于java - HttpGet 的 SSL 问题可能是因为服务器正在请求客户端身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17702388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com