Hello. You need to find a specific certificate on your computer. What attribute is required to search? serialNumber as I understand it is not unique.

For search I use the code:

 X509Certificate2Collection certificates; X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); certificates = store.Certificates.Find((X509FindType)filterType, filterValue, false); store.Close(); 

    1 answer 1

    Thumbprint Search:

     var thumbprint = Regex.Replace("‎d2 46 8d 22 87 ab b7 00 35 e7 e1 cf d9 8f 6c 3d a7 cf c3 42", @"[^\da-zA-z]", string.Empty).ToUpper(); using (var store = new X509Store(StoreName.My, StoreLocation.CurrentUser)) { store.Open(OpenFlags.ReadOnly); var certificates = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false); if (certificates.Count > 0) { var certificate = certificates[0]; Console.WriteLine($"Субъект: {certificate.Subject}"); }; } 
    • And there using no? - Qwertiy
    • @Qwertiy added using, for some reason in all examples through try catch do. If the store object implements IDisposable, means using norms? - Ruslan_K
    • It must be yes. - Qwertiy