java - 检索和使用 Microsoft 或 Mozilla 的 Root-CA 列表并在 Java 中使用?
问题描述
OpenJDK for Windows 中包含的根 CA 证书列表非常令人印象深刻,但有很多根 CA 证书受到常见浏览器(如 Firefox)的信任,而 Java 不信任这些证书。
Microsoft和Mozilla都发布了他们当前的根 CA 证书列表,但使用的文件格式似乎是专有的。
curl 项目有一个使用 Mozilla 文件作为源的自动转换器,但是这个转换器 ( mk-ca-bundle ) 是一个 Perl 脚本。
有没有办法用纯 Java 读取这些列表之一,以便之后可以用作信任存储?
解决方案
OpenJDK describes how they build the cacerts
file in the Security files for OpenJDK repo. The script downloads the certificates from Mozilla:
wget https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt .
As per the repo instructions you could build your own cacerts
file that will trust another list of certificates of your own choosing:
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
推荐阅读
- sql - 如何进行查询以获取用户的所有组,显示每个组拥有的用户(postgresql)
- python - 从未保存的 excel 工作簿上的 python 函数调用时,RefreshAll 函数在 excel 上不起作用
- html - 如何“即使页面滚动也能在正确的位置显示列表”
- tensorflow - 为什么 Tensorflow 官方 CNN 示例在我的机器上停留在 10% 的准确率(= 随机预测)?
- powershell - 比较 Powershell 中两个不同目录的 MD5 哈希值
- javascript - 使用复选框的响应式导航栏的 JavaScript 是否选中
- python - 熊猫数据框中每天的新出现次数(不计数或总和)
- triton - win10上安装nvidia-pyindex不成功
- css - 如何将表格标题中的文本垂直对齐到底部?
- sql - Oracle SQL 选择,比较 2 个 listagg 的值