I'm having issues using a client certificate to authenticate an HttpWebRequest
. (The client certificate isn't being sent). After some investigation, this seems to be because the certificate isn't passing verification.
To narrow down the problem, I'm using this example from MSDN (It's bugged, see end of this question. Also make sure you have a reference to System.Security
). It tells me that the verification is failing because it's unable to check the revocation status of the certificate (which makes sense, our CA doesn't have OCSP enabled) The certificates will be used in an offline deployment so it will never be able to check revocation anyway. Because of this, I want to disable the revocation check.
I've modified the example as follows
''~ line 29
ch.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck
ch.ChainPolicy.VerificationFlags =
X509VerificationFlags.IgnoreCertificateAuthorityRevocationUnknown Or
X509VerificationFlags.IgnoreCtlSignerRevocationUnknown Or
X509VerificationFlags.IgnoreEndRevocationUnknown Or
X509VerificationFlags.IgnoreRootRevocationUnknown
ch.Build(certificate)
Console.WriteLine("Chain Information")
Console.WriteLine("Chain revocation flag: {0}", ch.ChainPolicy.RevocationFlag)
...
Which unfortunately still results in my certificate failing verification
Element issuer name: [Obfuscated]
Element certificate valid until: 20/11/2013 17:50:01
Element certificate is valid: False
Element error status length: 0
Element information:
Number of element extensions: 8
Note that without the flags specified above, I get error status length: 1
which is 64. The revocation function was unable to check revocation for the certificate.
*****
So, clearly the flags are effecting something (I no longer get errors) but the certificate is not passing verification. Can someone explain why? Either I have another error that isn't being reported or I'm going about this in completely the wrong way.
*NB: There's a minor bug in the MSDN example ~ line 57. The for loop should check for element.ChainElementStatus.Length > 0
and then For index = 0 To element.ChainElementStatus.Length - 1
. Otherwise, the certificate still fails but no reason is displayed irrespective of the flags used