-1

Is there a way to add private key to certificate? API of Certificate authority app returns two base64 strings (one with private key, one with certificate without private part). I want to save the Resulting certificate onto smart card.

There are some answers but there are missing libraries or they don't work at all.

  • "There are some answers but there are missing libraries or they don't work at all." Why cannot you drill down into those failures? If a library is missing, simply find it. – Lex Li Jul 11 '18 at 14:12
  • I don't think you want to add an un-encrypted key to a document. The private key is suppose to be sent separate from the message to make is harder for somebody to de-crypt the message. – jdweng Jul 11 '18 at 14:14
  • Have you tried talking to your CA (about getting a cert with the private key included)? A certificate is digitally signed by the CA, you can't be messing around with it without messing up the signature. – Flydog57 Jul 11 '18 at 14:31

1 Answers1

0

What about building an X509Certificate2 from it, using e.g. Associate a private key with the X509Certificate2 class in .net

then, dump the certificate to PFX using certificate.Export(X509ContentType.Pkcs12,"password"), and dumping the byte[] to disk, and finally, launch:

certutil -importPFX <pfxFile> -p password -csp "Microsoft Smart Card Key Storage Provider" ...
PKI Guy
  • 43
  • 8