I have three certificates and need to verify them with each other. 1 root certificate and 2 leaf certificate.
Trying with this code block:
bool retVal = false;
X509Chain chain = new X509Chain();
chain.ChainPolicy.ExtraStore.Add(rootCertificate.X509);
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
retVal = chain.Build(leafCertificate.X509);
return retVal;
Im getting always false. Cannot find any different way on internet.
Thanks for your helps.
If you add untrusted certificate(s) to the chain you need to validate with the AllowUnknownCertificateAuthority flag. Try to add this
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
before you call chain.Build()
.