我正在使用此代码通过其指纹查找证书。证书存在于个人证书存储的证书管理器中,但此代码未找到该证书。
请告诉我我在哪里做错了。
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string certThumbPrint = "fe14593dd66b2406c5269d742d04b6e1ab03adb1";
X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
// Try to open the store.
certStore.Open(OpenFlags.ReadOnly);
// Find the certificate that matches the thumbprint.
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint, certThumbPrint, false);
certStore.Close();
// Check to see if our certificate was added to the collection. If no,
// throw an error, if yes, create a certificate using it.
if (0 == certCollection.Count)
{
Console.WriteLine("Error: No certificate found containing thumbprint " );
}
Console.ReadLine();
}