Java拒绝ssl证书,但Firefox接受它

时间:2015-11-26 20:31:07

标签: java firefox ssl https

我有这段代码:

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接受它,可以添加证书吗?

1 个答案:

答案 0 :(得分:1)

如果您使用SSLLabs分析此网站,它看起来很不错。但其中一条信息可能很重要:

  

此网站仅适用于支持SNI的浏览器。

如果您使用的软件不支持Server Name Indication (SNI),它将返回www.re-publica.de的证书,但也未包含必要的中间证书。因此验证失败。

我的猜测是你使用的是不支持SNI的Java版本(如Java 6)。

另一种选择是未安装必要的根CA.此证书的最终信任锚是StartCom证书颁发机构,您可以下载here