我创建这样的证书请求:X509Chain.Build()成功撤销证书。 C#
certreq -new req.inf req-Revoked.req
certreq -submit -attrib "SAN:[email protected]&[email protected]" -config Win2K8-64\Test-Win2K8-64-CA req-Revoked.req testerCert-Revoked.cer
certreq -accept testerCert-Revoked.cer
CertUtil -f -p testerCert -exportPFX -user My Testing.Tester.T.1234567890 testerCert-Revoked.pfx
CertUtil -delstore -user My Testing.Tester.T.1234567890
然后我撤消它,经由:
CertUtil -revoke <SerialNumber_from_above_Cert>
然后我执行此代码:
X509Certificate2 certificate = GetCertificate("testerCert-Revoked.pfx", "password"); // helper method loads the pfx from a file
X509Chain chain = new X509Chain();
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
chain.ChainPolicy.VerificationTime = DateTime.Now;
chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 0, 0);
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag;
if (!chain.Build(certificate))
{
errorBuffer.Append("Could not build X.509 certificate chain:\r\n");
foreach (X509ChainStatus status in chain.ChainStatus)
{
errorBuffer.AppendFormat(" - {0}\r\n", status.StatusInformation);
}
throw new CryptographicException(errorBuffer.ToString());
}
chain.Build()始终返回true。但是,由于证书被撤销,它应该是假的!我仔细检查了证书是否被吊销,并且序列号在服务器管理器中列在撤销证书下。我仔细检查了CURL分发点URL在服务器和证书请求上是否匹配。 (他们是LDAP网址)。 CertUtil将中间.cer文件视为已撤销。但上面的C#代码没有。
这一切都在原始CA过期之前就起作用了,并且IT使用新的证书重建了我的测试机器。我已经使用新的CA重新生成了证书,并且每个单元测试都再次运行,除了处理撤销的单元之外。已过期的证书按预期工作,但未撤销证书。
我不知道下一步该做什么,并且希望得到一些帮助。谢谢!
我也通过服务器管理器发布了CURL。 – ChopperCharles