0

In C#, I need to load a X509Certificate2 with an encrypted private key, imported from a .key file. The RSACryptoServiceProvider does not take any arguments to import such key, and my research has not provided any success.

I have tried this link.

The certificate is used to retrieve JSON from a REST API.

billven
  • 11
  • 2
  • 2
    .NET doesn't support PKCS#1 or PKCS#8 keys (though, CryptoAPI does). You need to convert your certificate and key to PKCS#12 file by using certitil tool: https://stackoverflow.com/a/48473273/3997611 and then use `X509Certificaye2(string, SecureString` constructor: https://msdn.microsoft.com/en-us/library/ms148419(v=vs.110).aspx – Crypt32 Apr 06 '18 at 12:36
  • @Crypt32 Thanks! Solved the problem! – billven Apr 06 '18 at 15:03

0 Answers0