Task:
It is required to check for validity all certificates in the root trusted certificate store, after digging into Google, found this option:
for each certificate to build
X509Chain
, the question arose of how this code works, or more precisely, how is the certificate validated?X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine); store.Open(OpenFlags.MaxAllowed); X509Certificate2Collection certificates = store.Certificates; foreach (X509Certificate2 cert in certificates) { X509Chain chain = new X509Chain(); chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; chain.Build(cert); ... bool revoked = false; foreach (X509ChainElement element in chain.ChainElements) { revoked = element.Certificate.Verify(); } }
There is also an option - I have an XML document that contains information on all the CAs I need, each CA has a certificate status and a url list on CRL files with certificate revocation lists, how can I read the list of revoked certificates from CRL file in C # and verify root certificate for this CRL file?
Looking for the best way to validate all root certificates (~ 700 pieces) written in C #