【发布时间】:2015-11-26 20:31:07
【问题描述】:
我有这个代码:
URL url = new URL("https://berlinbuzzwords.de/sites/berlinbuzzwords.de/files/media/documents/julien_nioche-low_latency_scalable_web_crawling_on_apache_storm.pdf");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.connect();
它失败了
Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
我知道我可以将证书添加到 JVM 并解决这个问题,但是 Firefox 接受这个 url,甚至说它是安全的。那么,为什么会发生这种情况?如果 Firefox 接受,是否可以添加证书?
【问题讨论】:
-
大多数时候它缺少证书链中的证书。或者 Java 中不包含的 CA。如果您打算在现场运行此程序,则仅将 CA 证书添加到本地 cacerts 可能是一种选择。但首先检查该证书及其链(可以在 Firefox 中进行)
-
该证书也显示了我的移动 chrome 中的问题。