当存在相同别名时,从 Windows-MY 获取证书
我试图从 windows-MY 检索所有证书,但其中一些证书具有相同的别名。
因此,以下代码段仅返回此别名的第一次出现:
KeyStore keyStore = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
Enumeration enumeration = keyStore.aliases();
while (enumeration.hasMoreElements()) {
String alias = enumeration.nextElement().toString();
keyStore.getCertificateChain(alias);
java.security.cert.Certificate[] chain = keyStore.getCertificateChain(alias);
...
}
是否有其他方法来检索证书?
I am trying to retrieve all the certificates from windows-MY, but some of them have the same alias.
So, the following piece of code return just the first occurence with this alias:
KeyStore keyStore = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
Enumeration enumeration = keyStore.aliases();
while (enumeration.hasMoreElements()) {
String alias = enumeration.nextElement().toString();
keyStore.getCertificateChain(alias);
java.security.cert.Certificate[] chain = keyStore.getCertificateChain(alias);
...
}
Is there another way to retrieve the certificates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有同样的问题。此 Sun bug 报告中提到的代码有效:
https://bugs.java.com/ bugdatabase/view_bug?bug_id=6672015
I had the same problem. The code mentioned in this Sun bug report works:
https://bugs.java.com/bugdatabase/view_bug?bug_id=6672015
你尝试过for循环吗?
Have you tried a for loop?