Read all system certificates

OSVBNET 1,386 Reputation points
2022-05-18T13:59:08.647+00:00

Hello,
I need to read and show ALL the certificates in the system
Unfortunately, X509Store.Certificates does not have a method like GetAllCertificates
Any better way than Find, or how to pass a MARK ALL like * to Find?
Where's Certificate.IssuedTo and Certificate.EmailAddress? How to get them?
Thanks for the help :)

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,564 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 47,716 Reputation points
    2022-05-18T15:16:55.273+00:00

    I'm a little confused because you said you want all certs but then you're trying to ask questions about finding certs. Note that there are a lot of certs on machines so enumerating them all is going to be slow.

    Certs are contained per store so to get all the certs you'd have to open all the stores one by one. For each store you can then use the Certificates property to enumerate the certs in that store.

       Dim store As New X509Store(StoreName.Root, StoreLocation.LocalMachine)  
       store.Open(OpenFlags.ReadOnly)  
         
       For Each cert In store.Certificates  
           Console.WriteLine($"Subject: {cert.Subject} Issuer: {cert.Issuer}")  
       Next  
       store.Close()  
    

    As for getting the email I don't know what you're referring to. There is no email associated with a cert. You can get the properties associated with a cert that may have some metadata that has an email but that would depend on the cert.

    The issued to and issuer are always the same from what I've seen.


0 additional answers

Sort by: Most helpful