Search code examples
c#.netcertificatersax509

How can I add a private key to X509Certificate2 after I have already added the public key?


My steps are:

  1. Create X509Certificate2 with public key:

    X509Certificate2 clientCertificate = new X509Certificate2("public key certificate blob as byte[]");
    
  2. How do I want to load the private key blob to clientCertificate?


Solution

  • It looks like you can not import RSA private key with just .net framework tools.

    Check out this thread How to read a PEM RSA private key from .NET.