C# 以 pfx 格式导出证书

发布于 2024-07-29 23:28:21 字数 179 浏览 5 评论 0原文

NET 将证书从证书存储导出到 PFX 文件中。 我尝试使用设置了 X509ContentType.Pfx 标志的 X509certificate2.Export 方法,但不确定如何处理返回的字节数组并将其正确输出到文件。

任何帮助表示赞赏。

NET to export a certificate from the cert store into a PFX file. I'm trying to use the X509certificate2.Export method with the X509ContentType.Pfx flag set, but am unsure how to handle the returned byte array and output it correctly to file.

Any help appreciated.

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

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

发布评论

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

评论(1

流年已逝 2024-08-05 23:28:22

从日期来看,您可能已经弄清楚了这一点,但您所要做的就是将返回的字节数组直接写入文件:

byte[] certData = cert.Export(X509ContentType.Pfx, "MyPassword");
File.WriteAllBytes(@"C:\MyCert.pfx", certData);

Judging by the date, you may have already figured this out, but all you have to do is write the returned byte array directly to a file:

byte[] certData = cert.Export(X509ContentType.Pfx, "MyPassword");
File.WriteAllBytes(@"C:\MyCert.pfx", certData);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文