使用 HTTPS(不可信证书)通过 Java 访问网站时出现问题
我尝试从 Java 应用程序使用 HTTP 访问站点。由于应用程序运行在开发环境中,因此相应的证书不受信任。
使用 javax.net.ssl 包时,我尝试定义一个自定义 TrustManager 实现,该实现允许所有内容并在 SslContext 的 init 方法的第二个参数中传递它,但这不起作用。
有人做这样的工作吗? 非常感谢您的帮助! 蒂埃里
I try to access a site using HTTP from a Java application. Since the application is running in a development environment, the corresponding certificate isn't trusted.
When using javax.net.ssl package, I try to define a custom TrustManager implementation that allows everything and pass it within the second parameter of the init method of the SslContext, but this doesn't work.
Does anybody make work something like that?
Thanks very much for your help!
Thierry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实现一个不验证任何内容的
TrustManager
非常容易(在客户端和服务器端均有效):要使用此
TrustManager
:请注意(如 @ 所说) hanwg)这样的信任管理器只能用于测试/原型设计目的。
It is pretty easy to implement a
TrustManager
which does not verify anything (works on both client and server side):To use this
TrustManager
:Please note that (as said by @hanwg) such a trust manager should only be used for testing/prototyping purposes.
如果您信任该证书,则应将其添加到应用程序服务器的信任库中。实施不执行证书检查的信任管理器是一个安全漏洞。
if you trust the certificate, you should add it to your application server's truststore. implementing a trust manager that doesn't perform certificate checking is a security vulnerability.