Convert .PFX to .PEM programmatically?

I need to programmatically extract the certificates and their secret keys from the MS certificate store and somehow get them in .PEM format. I do not want to use OpenSSL on the command line, since I would like to keep everything in memory, avoiding files.

I can export them from Windows to the PFX blob format using PFXExportCertStoreEx (). I tested this by writing it to a file and converting it to .PEM with OpenSSL. The resulting .PEM file works fine. So the remaining problem is to get them in .PEM format in memory.

We integrated another SSL library that wants .PEM. (This is not OpenSSL ...) Therefore, I would like to accomplish this without including the OpenSSL source in our C ++ project. Any ideas?

+3
source share
1 answer

What about static binding to OpenSSL.lib files?

I applied some examples using OpenSSL, for this you can find C ++ code to convert pfx to pem: https://github.com/michaelmotes/PKCS12toPEM

And this file contains the VB.NET Interop code to convert PFX to PEM using OpenSSL:

https://github.com/michaelmotes/libCurlVB.NET-native/blob/master/LibCurlDecl.vb

+1
source

Source: https://habr.com/ru/post/1721941/


All Articles