private static X509Certificate2 Find(string thumbprint)
{
var store = new X509Store(StoreLocation.CurrentUser);
try
{
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
var found = store.Certificates;
found = found.Find(X509FindType.FindByTimeValid, DateTime.Now, false);
found = found.Find(X509FindType.FindByThumbprint, thumbprint, false);
if (found.Count == 0)
return null;
return found[0];
}
finally
{
store.Close();
}
}