RevocationExtensions klasa

Extension metode za provjeru opoziva certifikata.


Definicija

namespace WvdS.System.Security.Cryptography.X509Certificates;
 
public static class RevocationExtensions

Metode

Metoda Opis
IsRevoked Provjerava je li certifikat opozvan
FetchCrlAsync Preuzima CRL s URL-a (iz certifikatnog proširenja)
CheckRevocationAsync Kombinirano: preuzimanje CRL-a i provjera opoziva
GetCrlDistributionPoints Ekstrahira CRL URL-ove iz certifikata
GetOcspUrls Ekstrahira OCSP URL-ove iz certifikata

Provjera opoziva

S postojećim CRL-om:

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($"Certifikat opozvan dana: {result.RevocationDate}");
    Console.WriteLine($"Razlog: {result.Reason}");
}

Automatsko preuzimanje CRL-a:

RevocationResult result = await certificate.CheckRevocationAsync(
    caCert,
    mode: CryptoMode.Hybrid);

RevocationResult klasa

Svojstvo Tip Opis
IsRevoked bool Certifikat je opozvan
RevocationDate DateTimeOffset? Vrijeme opoziva
Reason CrlReason? Razlog opoziva
CrlVerified bool CRL potpis je verificiran
Success bool Provjera je bila uspješna

CRL predmemorija

using var cache = new CrlCache(defaultCacheDuration: TimeSpan.FromHours(1));
 
// Provjera s automatskim CRL predmemoriranjem
RevocationResult result1 = await cache.CheckRevocationAsync(cert1, caCert);
RevocationResult result2 = await cache.CheckRevocationAsync(cert2, caCert); // CRL iz predmemorije

Vidi također


Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional

Zuletzt geändert: 29.01.2026. u 23:22