以编程方式将 .PFX 转换为 .PEM?

发布于 2024-08-10 06:18:37 字数 346 浏览 2 评论 0原文

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

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

我们集成了一个需要 .PEM 的不同 SSL 库。 (它不是 OpenSSL...)所以我想在不将 OpenSSL 源代码包含到我们的 C++ 项目中的情况下完成此任务。有什么想法吗?

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绅士风度i 2024-08-17 06:18:37

静态链接到 OpenSSL .lib 文件怎么样?

我已经使用 OpenSSL 改编了一些示例来执行此操作,您可以在此处找到将 pfx 转换为 pem 的 C++ 代码:
https://pubrepos.motes.camp/browse/libCurlVB.NET-native .git/

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

https://pubrepos.motes.camp/browse/libCurlVB.NET-native.git/blob/HEAD/LibCurlDecl.vb

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://pubrepos.motes.camp/browse/libCurlVB.NET-native.git/

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

https://pubrepos.motes.camp/browse/libCurlVB.NET-native.git/blob/HEAD/LibCurlDecl.vb

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文