0
我正在尝试调试https连接失败的原因。我得到的错误是在运行时查找HttpsURLConnection的信任库内容
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
该代码使用Java 7的内置信任库。
对于这种情况,有两个不同的机器(A和B)和一个服务器运行一个客户机(由我编写)。该连接从工作,但未能从B.我已经运行下面的代码登录信托管理者上述异常:
trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore)null);
for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) {
System.out.println(trustManager);
if (trustManager instanceof X509TrustManager) {
X509TrustManager x509TrustManager = (X509TrustManager)trustManager;
for (X509Certificate c : x509TrustManager.getAcceptedIssuers())
{
System.out.println(c.get);
}
}
}
此代码登录几乎在A和B相同的证书,并且最重要的是根两者都存在服务器所需的证书。
所以,我正在寻找一种方法来在运行时检查连接对象以确定实际使用的证书。有没有办法做到这一点?
更新:我无法获得ssl调试工作,所以我需要一种方法来以编程方式执行此操作。
中描述的调试JVM标志。在大多数情况下,这可能是正确的答案。但是,在这种情况下(我忘了在我的问题中提到,会更新它)我无法获得ssl调试工作。所以我正在寻找一种以编程方式获取信息的方式。 –
@AndersIvner你不能让它工作如何?为我工作了15年或更长时间。 – EJP
@EJP在,我们发送标志-Djavax.net.debug = ssl,但它仍然不会记录任何东西。这是一个复杂的系统,该标志在其他情况下有效,但在这种情况下不适用。 –