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);
}
}
Get all the certificates stored in the Microsoft certificate store.
We usually come accross the problem of getting all the certificates in the microsoft certificate store .This is required when we are searching on subject of root CA certificate stored in the certificate store to validate a certificate signed by the root certificte..


Join the conversation! Your thoughts help the community grow.