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

标签 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 接受,是否可以添加证书?

最佳答案

如果您使用 SSLLabs 分析此站点它看起来大部分都很好。但其中一个信息可能很重要:

This site works only in browsers with SNI support.

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

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

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

关于Java 拒绝 ssl 证书,但 Firefox 接受它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33946553/

相关文章:

amazon-web-services - AWS Elastic Beanstalk Namecheap SSL 配置

java - 如何制作一个网站的图标放到手机上

java - NsdManager 不解析多个发现的服务

java - 有没有人读过 Java 语言规范(JLS)?

jquery - Firefox:将文件上传对话框限制为仅 mp3

python - 我需要为带有 SSL 套接字连接的 Python 分发什么( key 、证书)?

Java:为什么我的程序会输出不正确的 else 语句?

Firefox iframe getCompulatedStyle bug 的 Javascript 解决方法

css - Firefox 中的渐变边框

Laravel Request::secure() 函数返回 false