Beispiel #1
0
 public static X509Certificate2 LoadCertificateByThumbprint(string thumbprint, bool requirePrivateKey)
 {
     StoreName[] array = new StoreName[]
     {
         StoreName.My,
         StoreName.Root
     };
     StoreLocation[] array2 = new StoreLocation[]
     {
         StoreLocation.CurrentUser,
         StoreLocation.LocalMachine
     };
     StoreName[] array3 = array;
     for (int i = 0; i < array3.Length; i++)
     {
         StoreName       storeName = array3[i];
         StoreLocation[] array4    = array2;
         for (int j = 0; j < array4.Length; j++)
         {
             StoreLocation    storeLocation   = array4[j];
             X509Certificate2 x509Certificate = CertUtils.TryLoadCertificate(thumbprint, requirePrivateKey, storeName, storeLocation);
             if (x509Certificate != null)
             {
                 return(x509Certificate);
             }
         }
     }
     return(null);
 }