【问题标题】:Find Certificate by hash in Store C#在 Store C# 中通过哈希查找证书
【发布时间】:2011-10-13 10:55:19
【问题描述】:

如何使用 C# 在 Windows Store 中通过哈希获取证书?

sha1 示例:7a0b021806bffdb826205dac094030f8045d4daa

这个循环有效,但是:

X509Store store = new X509Store(StoreName.My);

store.Open(OpenFlags.ReadOnly);

foreach (X509Certificate2 mCert in store.Certificates)
{
    Console.WriteLine( mCert.Thumbprint);
}

store.Close();

有直接的方法吗?

【问题讨论】:

    标签: c# .net store x509certificate


    【解决方案1】:

    使用Find method on the collection

    store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, true)
    

    【讨论】:

      【解决方案2】:
      var cert = store.Certificates.Find(
                                          X509FindType.FindByThumbprint,
                                          thumbprint,
                                          true
                                        ).OfType<X509Certificate>().FirstOrDefault();
      

      【讨论】:

        猜你喜欢
        • 2011-10-15
        • 2018-04-03
        • 2012-09-20
        • 1970-01-01
        • 1970-01-01
        • 2012-06-22
        • 2020-02-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多