以编程方式将.PFX转换为.PEM? [英] Converting .PFX to .PEM programmatically?

查看:587
本文介绍了以编程方式将.PFX转换为.PEM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以编程方式从MS证书存储中提取证书及其私钥,并以某种方式将它们转换为.PEM格式。我不想在命令行使用OpenSSL,因为我想保留一切内存,避免文件。

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 to use OpenSSL at the command line, as I would like to keep everything in memory, avoiding files.

我可以将它们从Windows导出到PFX格式blob使用PFXExportCertStoreEx()。我测试了,通过将其写入一个文件,并将其转换为.PEM与OpenSSL。生成的.PEM文件工作正常。所以剩下的问题是让他们在内存中的.PEM格式。

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.

我们已经集成了一个不同的SSL库,想要。 (它不是OpenSSL ...)所以我想实现这一点,而不包括OpenSSL源代码到我们的C + +项目。任何想法?

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?

推荐答案

如何静态链接到OpenSSL .lib文件?

How about statically linking to OpenSSL .lib files?

我已经修改了一些使用OpenSSL的例子,你可以找到c ++代码将pfx转换为pem:
https://github.com/michaelmotes/PKCS12toPEM

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

此文件包含用于使用OpenSSL将PFX转换为PEM的VB.NET Interop代码:

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

这篇关于以编程方式将.PFX转换为.PEM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆