从 Java 连接到 HTTPS 服务器并忽略安全证书的有效性
我一直在测试一个系统,该系统使用不同的密钥访问一组 https 服务器,其中一些密钥无效,并且所有密钥都不在我的 JVM 的本地密钥存储中。我实际上只是在测试,所以现阶段我并不关心安全性。有没有一种好方法可以对服务器进行 POST 调用并告诉 Java 不要担心安全证书?
我对此进行的谷歌搜索带来了一些代码示例,这些示例使一个类进行验证,该示例始终有效,但我无法让它连接到任何服务器。
I've been testing a system that accesses a group of https servers with different keys, some of which are invalid and all of them are not in the local key store for my JVM. I am really only testing things out, so I don't care about the security at this stage. Is there a good way to make POST calls to the server and tell Java not to worry about the security certificates?
My google searches for this have brought up some code examples that make a class to do the validation, that always works, but I cannot get it to connect to any of the servers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据评论:
更新:链接已损坏,因此这是我从 互联网档案:
As per the comments:
Update: the link broke, so here's an extract of relevance which I saved from the internet archive:
您需要创建一个绕过所有安全检查的 X509TrustManager。您可以在我对此问题的回答中找到一个示例,
如何忽略 Apache HttpClient 4.0 中的 SSL 证书错误
You need to create a X509TrustManager which bypass all the security check. You can find an example in my answer to this question,
How to ignore SSL certificate errors in Apache HttpClient 4.0