X509Chain似乎忽略了RevocationMode和VerificationFlags

Bas*_*sic 6 .net security ssl client-certificates ssl-certificate

我在使用客户端证书进行身份验证时遇到问题HttpWebRequest.(未发送客户端证书).经过一番调查,这似乎是因为证书没有通过验证.

为了缩小问题范围,我正在使用MSDN中的这个示例(它有问题,请参阅此问题的结尾.另外请确保您有参考System.Security).它告诉我验证失败,因为它无法检查证书的撤销状态(这是有道理的,我们的CA没有启用OCSP)证书将用于脱机部署,因此它永远无法检查无论如何撤销.因此,我想禁用撤销检查.

我修改了这个例子如下

''~ 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)
...
Run Code Online (Sandbox Code Playgroud)

遗憾的是,我的证书仍未通过验证

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
Run Code Online (Sandbox Code Playgroud)

请注意,没有上面指定的标志,我得到的error status length: 164. The revocation function was unable to check revocation for the certificate.*****

所以,显然标志正在影响某些东西(我不再出错),但证书没有通过验证.有人可以解释原因吗?要么我有另一个没有报告的错误,要么我完全以错误的方式解决这个问题.

*注意:在MSDN示例〜第57行中有一个小错误.for循环应该检查element.ChainElementStatus.Length > 0然后For index = 0 To element.ChainElementStatus.Length - 1.否则,证书仍会失败,但无论使用哪个标志,都不会显示任何原因