Extension methods for checking certificate revocation.
namespace WvdS.System.Security.Cryptography.X509Certificates; public static class RevocationExtensions
| Method | Description |
|---|---|
| IsRevoked | Checks if a certificate is revoked |
| FetchCrlAsync | Loads CRL from URL (from certificate extension) |
| CheckRevocationAsync | Combined: Load CRL and check revocation |
| GetCrlDistributionPoints | Extracts CRL URLs from certificate |
| GetOcspUrls | Extracts OCSP URLs from certificate |
With existing CRL:
var certificate = new X509Certificate2("user.cer"); byte[] crlData = File.ReadAllBytes("ca.crl"); var caCert = new X509Certificate2("ca.cer"); RevocationResult result = certificate.IsRevoked(crlData, caCert, CryptoMode.Hybrid); if (result.Success && result.IsRevoked) { Console.WriteLine($"Certificate revoked on: {result.RevocationDate}"); Console.WriteLine($"Reason: {result.Reason}"); }
Load CRL automatically:
RevocationResult result = await certificate.CheckRevocationAsync( caCert, mode: CryptoMode.Hybrid);
| Property | Type | Description |
|---|---|---|
IsRevoked | bool | Certificate is revoked |
RevocationDate | DateTimeOffset? | Time of revocation |
Reason | CrlReason? | Revocation reason |
CrlVerified | bool | CRL signature was verified |
Success | bool | Check was successful |
using var cache = new CrlCache(defaultCacheDuration: TimeSpan.FromHours(1)); // Check with automatic CRL caching RevocationResult result1 = await cache.CheckRevocationAsync(cert1, caCert); RevocationResult result2 = await cache.CheckRevocationAsync(cert2, caCert); // CRL from cache
Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional