Windows 版 OpenJDK 中包含的根 CA 证书列表令人印象深刻,但有许多根 CA 证书受 Firefox 等常见浏览器信任,但不受 Java 信任。
两者都是Microsoft和 Mozilla发布他们当前的根 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
文件,该文件将信任您自己选择的另一个证书列表:
Download the following Perl script: https://raw.githubusercontent.com/curl/curl/master/lib/mk-ca-bundle.pl
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)
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 scriptUse the cacerts provided: it must be in the
jdk/jre/lib/security
orjdk/lib/securityfolder
关于java - 检索和使用 Microsoft 或 Mozilla 的 Root-CA 列表并在 Java 中使用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56493968/