【发布时间】:2012-08-15 19:32:38
【问题描述】:
在 .Net 4.0 中,我无法使用 X509Store 的 find 方法从自定义存储中获取证书。使用以下代码:
X509Store store = new X509Store(storeName, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySubjectName, commonName,false);
【问题讨论】:
-
证书是否肯定在 CurrentUser 存储而不是机器存储?
-
你得到一个异常,还是 Find 只返回 null?
-
@ShellShock 它将提供一个包含 0 个项目的集合,并且我得到一个超出范围的异常:索引超出范围。必须是非负数且小于集合的大小。参数名称:index 当我尝试使用集合时
-
@BobVale 是的,它显示了 MMC 中的当前用户存储
标签: c# .net cryptography x509certificate2