如何在 Java 中获取受信任的根证书列表?
我希望能够在 Java 应用程序中以编程方式访问所有受信任的根证书。
我正在查看密钥库界面,但我希望获得 JRE 隐含的可信根列表。
这在任何地方都可以访问吗?
I would like to be able to get access to all trusted root certificates programmatically in a Java app.
I was looking at the keystore interface, but I'm hoping to get the list of trusted roots that's implicit with the JRE.
Is this accessible anywhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一个示例演示如何获取一组根证书并迭代它们,名为 列出密钥库中最受信任的证书颁发机构 (CA)。这是一个稍微修改过的版本,可以打印每个证书(在 Windows Vista 上测试)。
There's an example that shows how to get a Set of the root certificates and iterate through them called Listing the Most-Trusted Certificate Authorities (CA) in a Key Store. Here's a slightly modified version that prints out each certificate (tested on Windows Vista).
使用系统中的默认信任存储来获取所有证书应该更灵活:
```
This should be more flexible using the default trust store in the system to get all certificates:
```
一个工作示例,结合了蜥蜴比尔的概念和 k_o_ 答案:
A working example, combining concept from Bill the Lizard and k_o_ answer: