java - 检索和使用 Microsoft 或 Mozilla 的 Root-CA 列表并在 Java 中使用它?

标签 java ssl truststore root-certificate

Windows 版 OpenJDK 中包含的根 CA 证书列表令人印象深刻,但有许多根 CA 证书受 Firefox 等常见浏览器信任,但不受 Java 信任。

两者都是MicrosoftMozilla发布他们当前的根 CA 证书列表,但使用的文件格式似乎是专有的。

curl 项目有一个使用 Mozilla 文件作为源的自动转换器,但是这个转换器 (mk-ca-bundle) 是一个 Perl 脚本。

有没有办法用纯 Java 读取其中一个列表,以便以后可以将其用作信任库?

最佳答案

OpenJDK 在 Security files for OpenJDK repo 中描述了他们如何构建 cacerts 文件.该脚本从 Mozilla 下载证书:

wget https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt .

根据 repo 说明,您可以构建自己的 cacerts 文件,该文件将信任您自己选择的另一个证书列表:

  1. Download the following Perl script: https://raw.githubusercontent.com/curl/curl/master/lib/mk-ca-bundle.pl

  2. Download the following Java application: https://github.com/use-sparingly/keyutil/releases/download/0.4.0/keyutil-0.4.0.jar (source available at https://github.com/use-sparingly/keyutil)

  3. Run the provided GenerateCertsFile.sh script with: bash ./GenerateCertsFile.sh - this will use the above files assuming they're located in the same directory as the script

  4. Use the cacerts provided: it must be in the jdk/jre/lib/security or jdk/lib/securityfolder

关于java - 检索和使用 Microsoft 或 Mozilla 的 Root-CA 列表并在 Java 中使用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56493968/

相关文章:

java - Windows 和 Linux 的文件路径名

java - 在单独的表中映射 @Embeddable

java - 如何在用户浏览器中更改 url 而无需在 servlet 中进行客户端重定向

android - 客户端/服务器通信被阻止(可能被防火墙阻止)

ssl - 如何修复从 jks 到 pkcs12 的信任库类型

ssl - ActiveMQ Artemis "needClientAuth=true"错误输出 "Empty client certificate chain."消息 (AMQ222208)

java - JMF 注册表无法添加项目 (Vista)

ssl - 证书链在 Firefox 中不可见

javascript - 通过javascript以编程方式将证书导入firefox受信任的根CA

java - 仅具有 https URL 时获取证书并将其添加到 Java 信任库?