In my C# project I pass a custom implementation of the RemoteCertificateValidationCallback delegate to an SslStream. It is then used to validate a server certificate. The custom implementation checks the sslPolicyErrors flag that the default implementation has set and invokes custom logic based on the results. The default implementation sets flags for several types of certificate issues such as mismatched Subject name, an incomplete certificate chain or if the certificate is expired. My question: Can I infer in any way, from the result of the default implementation of RemoteCertificateValidationCallback, that the certificate is revoked (i.e. is listed in any type of CRL)? Or am I required to add custom logic to my own implementation of RemoteCertificateValidationCallback for a revocation check?
In other words, in the sample code below, if the certificate is revoked will this in any way be reflected in the sslPolicyErrors
flag, the certificate
object, or the chain
object? Or will I have to add additional logic for the revocation check?
RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
{
if (sslPolicyErrors == SslPolicyErrors.None)
{
return true;
}
else if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateNameMismatch)
{
// Custom check by additional data available for the certificate...
}
else
{
return false;
}
}