【问题标题】:Check if end user certificate installed in windows keystore?检查最终用户证书是否安装在 Windows 密钥库中?
【发布时间】:2011-09-21 01:17:44
【问题描述】:

如果 PKI 最终用户证书安装在用户 Windows 密钥库(个人)中,是否有任何方法可以检查 C#? (例外会做吗?)我会传递一些属性,比如 Name。

【问题讨论】:

    标签: c# certificate keystore


    【解决方案1】:

    您可以使用X509Store 类在系统上搜索证书。下面的代码示例在当前用户的个人存储中查找主题名称为“XYZ”的证书。

    System.Security.Cryptography.X509Certificates.X509Store store = new System.Security.Cryptography.X509Certificates.X509Store(StoreName.My, StoreLocation.CurrentUser);
    store.Open(OpenFlags.ReadOnly); // Dont forget. otherwise u will get an exception.
    X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindBySubjectName,"XYZ",true);
    if(certs.Count > 0)
    {
        // Certificate is found.
    }
    else
    {
        // No Certificate found by that subject name.
    }
    

    【讨论】:

      猜你喜欢
      • 2017-05-10
      • 1970-01-01
      • 2012-04-22
      • 2018-08-18
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 2012-08-02
      • 2017-12-10
      相关资源
      最近更新 更多