X509VerificationFlags are suppressions, so specifying X509VerificationFlags.AllFlags actually prevents Build from returning false in most situations.
The answer of RevocationStatusUnknown seems especially relevant. What certificate does it report that for it cannot be confirmed that it is not revoked. Verify method can be modeled as
public bool Verify() { using (X509Chain chain = new X509Chain()) {
That, because it does not approve X509VerificationFlags.IgnoreCertificateAuthorityRevocationUnknown or X509VerificationFlags.IgnoreEndRevocationUnknown , when it requests an X509RevocationMode other than None , fails.
First you must determine which certificates are missing in the chain (/ are):
using (X509Chain chain = new X509Chain()) { // The defaults, but expressing it here for clarity chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot; chain.ChainPolicy.VerificationTime = DateTime.Now; chain.Build(cert); for (int i = 0; i < chain.ChainElements.Count; i++) { X509ChainElement element = chain.ChainElements[i]; if (element.ChainElementStatus.Length != 0) { Console.WriteLine($"Error at depth {i}: {element.Certificate.Subject}"); foreach (var status in element.ChainElementStatus) { Console.WriteLine($" {status.Status}: {status.StatusInformation}}}"); } } } }
If you look at any invalid certificate in Windows CertUI (double-click the .cer icon in Explorer or in the MMC Certificates snap-in), find the "CRL Distribution Points" field. These are the URLs that will be received at runtime. Your system may have a data output restriction that prevents you from requesting these specific values. You can always try publishing a web request from your web service to see if it can retrieve URLs without the context of being present in the certificate subsystem.
bartonjs
source share