Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read certificates from my certificate store?

I want to install a certificate on a machine if it doesn't have it installed already. I tried checking if the store contains the certificate but somehow my store is always empty. I checked "Intermediate Certification Authorities" folder and found 18 certificates there. So why does this code write 0?

X509Store store = new X509Store(StoreName.CertificateAuthority, StoreLocation.LocalMachine);
Console.WriteLine(store.Certificates.Count);

I also tried StoreLocation.CurrentUser. What am I doing wrong?

like image 633
agnieszka Avatar asked Jan 04 '10 10:01

agnieszka


1 Answers

You have to call store.Open(OpenFlags.ReadWrite); before you can access the certificates.

like image 136
Pent Ploompuu Avatar answered Nov 10 '22 00:11

Pent Ploompuu