Get all the certificates stored in the Microsoft certificate store.


Use below mentioned code to get all the root certificates(with subject "CN=Certiposte Classe A Personne, O=Certiposte, C=FR") stored in the certificate store .


X509Store store = new X509Store("ROOT", StoreLocation.CurrentUser);
store.Open(
OpenFlags.ReadWrite);
X509Certificate2Collection storecollection = (X509Certificate2Collection)store.Certificates;
RegistryKey key;



string subjectToSearch = "CN=Certiposte Classe A Personne, O=Certiposte, C=FR"

foreach
(X509Certificate2 x509 in storecollection)
 {

     if (x509.subject = = subjectToSearch)
  
    {
         Console.WriteLine(x509.IssuerName);
     }
    

 }