How to check certificate revocation status in c#?

976 Views Asked by At

The certificate should be revoked if exists in the revocation list. There is an option in .net by which you'll be able to check the certificate revocation. I need to explore my certificate in the revocation list and revoke it, it exists in the revocation list. Therefore, I use the below one-line code to do that:

ServicePointManager.CheckCertificateRevocationList = true;

The problem is that the above code does not work properly. I mean certificate revocation will never be checked. For example, If I revoke the certificate manually certificate is still working. Is there any help?

2

There are 2 best solutions below

0
Shay Vaturi On

You can use X509Certificate2.Verify as described here:

X509Certificate2.Verify

You can load your certificate and verify it by calling the verify method.

0
Virgil On

https://github.com/dotnet/runtime/issues/88814 - in recent versions of .NET, HttpClient does not check the global ServicePointManager.CheckCertificateRevocationList property - it uses the one on the HttpClientHandler instead.