下面的java代码:
new URL("https://www.limagrain.com/").openStream()
Run Code Online (Sandbox Code Playgroud)
引发以下错误:
javax.net.ssl.SSLHandshakeException thrown: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Run Code Online (Sandbox Code Playgroud)
但是,该站点使用的根证书(Thawte Primary Root CA - G3)存在于 java 的信任存储中,并且该站点在浏览器中显示没有问题。
在Qualys SSL checker上检查该站点会给出有关标记为extra download的中间证书的警告。
如何让java自动下载中间证书?
将系统属性设置com.sun.security.enableAIAcaIssuers为true.
System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
Run Code Online (Sandbox Code Playgroud)
请参阅 Oracle 的 Java PKI 指南:https : //docs.oracle.com/javase/7/docs/technotes/guides/security/certpath/CertPathProgGuide.html#AppB。
| 归档时间: |
|
| 查看次数: |
3768 次 |
| 最近记录: |