Problems with X509Store Certificates.Find FindByThumbprint

后端 未结 14 2083
醉话见心
醉话见心 2020-12-04 20:56

I\'m having a problem when I use the method X509Store.Certificates.Find

public static X509Certificate2 FromStore(StoreName storeName, 
                  


        
14条回答
  •  失恋的感觉
    2020-12-04 21:22

    I ran into this same thing. I couldn't find this answer anywhere in here so I'll post it. It seems for me the X509Store find function just was flat not working. I verified this by a simple for loop and retrieving the cert manually.

      X509Store store = new X509Store(StoreName.Root,StoreLocation.LocalMachine);
            store.Open(OpenFlags.ReadOnly);
            X509Certificate cert = new X509Certificate();
            for (int i = 0; i < store.Certificates.Count; i++)
            {
                if (store.Certificates[i].SerialNumber == "XXXX")
                {
                    cert = store.Certificates[i];
                }
            }
    

提交回复
热议问题