开发者

Converting .PFX to .PEM programmatically?

开发者 https://www.devze.com 2022-12-10 02:13 出处:网络
I need to programmatically extract certificates and their private keys from a MS certificate store, and get them to the .PEM format somehow.I don\'t want t开发者_如何学JAVAo use OpenSSL at the command

I need to programmatically extract certificates and their private keys from a MS certificate store, and get them to the .PEM format somehow. I don't want t开发者_如何学JAVAo use OpenSSL at the command line, as I would like to keep everything in memory, avoiding files.

I can export them from Windows to a PFX-format blob using PFXExportCertStoreEx(). I tested that 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 to the .PEM format in memory.

We've integrated a different SSL library that wants .PEM. (It's not OpenSSL...) So I'd like to accomplish this without also including OpenSSL source into our C++ project. Any ideas?


How about statically linking to OpenSSL .lib files?

I have adapted some examples using OpenSSL to do this, you can find c++ code to convert pfx to pem here: https://github.com/michaelmotes/PKCS12toPEM

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消