0

I have a crl file. "Sample.crl", I need to install that into LocalStore using C# in windows.

 var decodedCertificateCollection = new X509Certificate2Collection(); 
 var certBytes = File.ReadAllBytes("sample.crl");
 decodedCertificateCollection.Import(certBytes); //throws error

 X509Store revokedStore = new X509Store(StoreName.Disallowed, StoreLocation.LocalMachine);
 revokedStore.Open(OpenFlags.ReadWrite);
 revokedStore.AddRange(decodedCertificateCollection )

The above code throws

"System.Security.Cryptography.CryptographicException: Cannot find the requested object"

Though I find some questions already, those are 10 years old, and I am wondering do we have a way in c# to do this today without the need of Win32 or thirdParty libraries.

saravanan
  • 398
  • 4
  • 13
  • what you are doing makes zero sense. You are trying to import CRL into certificate object. Certificates and CRLs are completely different things. .NET doesn't support CRLs, so you have to use `certutil.exe` command-line tool or use p/invoke: https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certaddcrlcontexttostore – Crypt32 Jun 02 '21 at 07:08
  • Google/Bing/etc. is your best friend. There are plenty examples and solutions. – Crypt32 Jun 02 '21 at 07:18

0 Answers0