Search code examples
sslclient-certificatesx509certificate2

Which X509 StoreName refers to the certificates stored beneath Trusted Root Certification Authorities in Windows10


When enumerating the AuthRoot and CertificateAuthorities X509 stores, I have been unable to find a self-signed SSL certificate that was imported into Trusted Root Certification Authorities on the local machine:

        X509Store store = new X509Store(StoreName.AuthRoot);  // also tried StoreName.CertificateAuthorities
        store.Open(OpenFlags.ReadOnly);
        var storecollection = (X509Certificate2Collection) store.Certificates;
        foreach (X509Certificate2 x509 in storecollection)
        {
            Console.WriteLine("certificate name: {0}", x509.Subject);
        }

Are self-signed SSL certificates skipped over as invalid by the enumerator? Am I looking in the wrong place?

Here's what I see in the Certificates snap-in in MMC:

MMC Certificates snap-in


Solution

  • StoreName.Root is what you want for "Trusted Root Certification Authorities".

    AuthRoot is "Third-Party Root Certification Authorities", and CertificateAuthority is "Intermediate Certification Authorities".