我有一个第三方 Java 应用程序。它尝试通过 HTTPS 下载文件。可悲的是,在我公司的网络中,HTTPS 被拦截,证书被替换为无根自定义证书。
现在虽然我在 /etc/ssl/certs/java/cacerts
中有我们的非根 CA(双重检查)它仍然无法下载:
java.io.IOException: Error downloading [https://zlib.net/zlib-1.2.11.tar.gz] to /tmp/zlib-1.2.11.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
有什么方法可以调试 JAVA 试图在内部进行证书验证的操作吗? 像这样的东西:
- 它正在加载哪些 CA
- 验证需要哪些步骤
- 验证失败的原因(详细)
如果我不需要使用反射或其他晦涩的东西,可以加分;)
最佳答案
我会尝试使用动态调试实用程序。有一个选项可以打开 SSL 调试,这应该对您有所帮助。
JSSE provides dynamic debug tracing support. This is similar to the support used for debugging access control failures in the Java SE platform. The generic Java dynamic debug tracing support is accessed with the java.security.debug system property, whereas the JSSE-specific dynamic debug tracing support is accessed with the javax.net.debug system property. Current options are:
all: Turn on all debugging ssl: Turn on SSL debugging
The following can be used with the ssl option:
record: Enable per-record tracing handshake: Print each handshake message keygen: Print key generation data session: Print session activity defaultctx: Print default SSL initialization sslctx: Print SSLContext tracing sessioncache: Print session cache tracing keymanager: Print key manager tracing trustmanager: Print trust manager tracing
我认为这应该对您有所帮助。
关于java - 如何调试 Java HTTPS 证书验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59183640/