====== RevocationExtensions Klasse ====== Extension Methods für die Prüfung von Zertifikatswiderruf. ---- ===== Definition ===== namespace WvdS.System.Security.Cryptography.X509Certificates; public static class RevocationExtensions ---- ===== Methoden ===== ^ Methode ^ Beschreibung ^ | IsRevoked | Prüft ob ein Zertifikat widerrufen ist | | FetchCrlAsync | Lädt CRL von URL (aus Zertifikat-Extension) | | CheckRevocationAsync | Kombiniert: CRL laden und Widerruf prüfen | | GetCrlDistributionPoints | Extrahiert CRL-URLs aus Zertifikat | | GetOcspUrls | Extrahiert OCSP-URLs aus Zertifikat | ---- ===== Widerruf prüfen ===== **Mit vorhandener 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($"Zertifikat widerrufen am: {result.RevocationDate}"); Console.WriteLine($"Grund: {result.Reason}"); } **CRL automatisch laden:** RevocationResult result = await certificate.CheckRevocationAsync( caCert, mode: CryptoMode.Hybrid); ---- ===== RevocationResult Klasse ===== ^ Eigenschaft ^ Typ ^ Beschreibung ^ | ''IsRevoked'' | bool | Zertifikat ist widerrufen | | ''RevocationDate'' | DateTimeOffset? | Zeitpunkt des Widerrufs | | ''Reason'' | CrlReason? | Widerrufsgrund | | ''CrlVerified'' | bool | CRL-Signatur wurde verifiziert | | ''Success'' | bool | Prüfung war erfolgreich | ---- ===== CRL-Cache ===== using var cache = new CrlCache(defaultCacheDuration: TimeSpan.FromHours(1)); // Prüfung mit automatischem CRL-Caching RevocationResult result1 = await cache.CheckRevocationAsync(cert1, caCert); RevocationResult result2 = await cache.CheckRevocationAsync(cert2, caCert); // CRL aus Cache ---- ===== Siehe auch ===== * [[.:certificaterevocationlistextensions|CertificateRevocationListExtensions]] * [[.:x509chainextensions|X509ChainExtensions]] ---- //Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional// {{tag>crl revocation widerruf ocsp}}