I've got a .PEM file that I want to convert to a PKCS12 file (PFX) and I know I can easily accomplish this using the following openssl command:
Create a PKCS#12 file: openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate"
Which is great, but I'd like to do this programmatically using openssl calls. Unfortunately, documentation for OpenSSL is less than.
I've looked into doing this using other libraries:
Using .NET: I can create a X509Certificate2 object from a PEM file, but this only grabs the first certificate and ignores any intermediate CA's in the PEM file.
Using Mentalis.org Security Library: I can create a Certificate object from PEM file, but I see the following in the documentation:
Remarks This implementation only reads certificates from PEM files. It does not read the private key from the certificate file, if one is present.
So, that doesn't help me. I need that private key too.
I basically need to recreate the Openssl command line tool operation for going PEM>PFX, but in code.
Anyone know an easier way to do this?