【问题标题】:Export certificate as pfx将证书导出为 pfx
【发布时间】:2019-12-11 08:51:13
【问题描述】:

我正在尝试将我的证书导出为 pfx。我正在这样做我的 certmgr.msc 但有些选项是灰色的。 certmgr 所以我想为此使用Powershell。 我要去证书所在的目录(cert:\CurrentUser\My),我正在归纳一个语法:

Export-PfxCertificate -Cert .\4BBB***************************** -FilePath 'C:\Users\jwozniak\Documents\outfile.pfx' -Password (ConvertTo-SecureString -String 'password63' -AsPlainText -Force)

(当然没有 *)

我收到以下错误:

不胜感激。

【问题讨论】:

  • 最好直接添加有问题的错误,而不是添加图片。
  • 编辑:现在我有一个错误“无法导出不可导出的私钥”问题是:如何导入带有选项导出私钥的证书?
  • 证书(在 Windows 上)具有导出策略。除了使用 github.com/gentilkiwi/mimikatz 之外,您无法解决这个问题

标签: certificate private-key pfx p12


【解决方案1】:

创建证书时,您需要使私钥具有“可导出”。 然后只有Export-PfxCertificate 命令可以正常工作而不会出错。

一些可能对你有帮助的例子:

1)通过将私钥标记为可导出来创建自签名证书

$cert = New-SelfSignedCertificate -DnsName $certname -certStorelocation cert:\localmachine\my -KeyLength 2048 -KeyFriendlyName $certname -FriendlyName $friendlyName -HashAlgorithm sha256 -Keyexportpolicy Exportable

这里的参数 -Keyexportpolicy 起到了重要的作用。

2)对于您的问题如何使用选项可导出私钥导入证书? 执行以下命令

 Import-PfxCertificate -FilePath C:\Temp\$certname.pfx -CertStoreLocation Cert:\LocalMachine\Root -Password $certpwd1 -Exportable

这里的参数 -Exportable 为服务目的发挥了重要作用

【讨论】:

    【解决方案2】:

    证书(在 Windows 上)具有导出策略。除了使用 https://github.com/gentilkiwi/mimikatz

    之外,您无法解决这个问题

    【讨论】:

      猜你喜欢
      • 2016-12-14
      • 2014-10-21
      • 2010-11-13
      • 2010-10-22
      • 1970-01-01
      • 2017-06-03
      • 2022-01-01
      • 2013-09-18
      相关资源
      最近更新 更多