6

我在使用客户端证书对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)
...

不幸的是,这仍然导致我的证书验证失败

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

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

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

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

4

0 回答 0