我尝试使用代码读取已安装的证书
KeyStore ks = KeyStore.getInstance("Windows-MY")
ks.load(null, null)
Enumeration<String> enumeration = ks.aliases()
while (enumeration.hasMoreElements()) {
String string = (String) enumeration.nextElement()
System.out.println(string)
}
此代码列出了 Windows 上已安装的证书,但 Linux 上没有列出?还尝试更改 keystore 提供商。
最佳答案
我不确定“读取浏览器证书”是什么意思。 您是否尝试从默认 Java keystore 读取证书?你的目标是什么?
KeyStore.getInstance(..) 使用特定类型(例如 JKS)实例化 keystore 。当您想要从特定 keystore 读取时,您需要指定 keystore 的路径并使KeyStore实例加载该文件。
参见http://www.java2s.com/Code/Java/Security/RetrievingaKeyPairfromaKeyStore.htm举个例子 https://docs.oracle.com/javase/8/docs/api/java/security/KeyStore.html了解更多详情。
已编辑:澄清问题后更新答案。
您可以在以下位置找到有关在 Linux 中读取浏览器 keystore 的更多信息:
关于java - 如何在Linux上使用java读取浏览器证书?通过使用 keyStore.getInstance ("xyz"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35647541/