c#验证CRL列表中的证书

use*_*816 6 c# certificate

如何以编程方式检查某个证书是否从其CA CRL列表中撤销?

我这样做:

X509Chain ch = new X509Chain();
ch.ChainPolicy.RevocationMode = X509RevocationMode.Online;
ch.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain;
ch.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(1000);
ch.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag;
ch.ChainPolicy.VerificationTime = DateTime.Now;
ch.Build(certificate);
foreach (X509ChainStatus s in ch.ChainStatus)
{
    string str = s.Status.ToString();
    Console.WriteLine("str: " + str);
}
X509Store store = new X509Store(StoreName.Disallowed, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadWrite);
bool isRevoked = store.Certificates.Contains(certificate);
store.Close();
return !isRevoked && certificate.Verify();
Run Code Online (Sandbox Code Playgroud)

我得到"str:RevokedStatusUnknown".只有在我撤销证书后等待很多个小时 - >状态才会返回为已撤销,尽管我在撤销证书后立即发布了CRL.为什么它不能立即访问CRL?

g01*_*01d 1

尝试运行以下 MS 命令。

   certutil -urlcache * delete
Run Code Online (Sandbox Code Playgroud)

Windows 会缓存证书吊销状态一段时间,使用上述命令将刷新缓存。