Export-PfxCertificate:无法导出不可导出的私钥 [英] Export-PfxCertificate : Cannot export non-exportable private key
问题描述
我正在尝试导出我的自签名证书,以便我可以将其导入到我的开发环境中的其他服务器(将使用真实"证书进行生产),但它引发了以下错误:
I am attempting to export my self-signed certificate so I can import it to other Servers in my development environment (will use "real" certs for Production), but it throws the following error:
Export-PfxCertificate:无法导出不可导出的私钥
Export-PfxCertificate : Cannot export non-exportable private key
要求是我需要导出证书并允许导出私钥",但很好奇我缺少什么.我的PowerShell如下:
The requirements are that I need to export the cert and "allow the private key to be exported", but am curious what I am missing. My PowerShell is as follows:
$pwd = ConvertTo-SecureString -String ‘1234’ -Force -AsPlainText
$path = 'cert:\localMachine\my\' + '1E7439053EE57AEE6EA0E1F3CDF5DB4234B6731E'
Export-PfxCertificate -cert $path -FilePath c:\Certificates\cert.pfx -Password $pwd
推荐答案
问题不在于 powershell 代码.问题出在证书上.
The problem isn't with the powershell code. The problem is with the certificate.
首次导入或创建证书时,必须将私钥标记为可导出,以便您能够导出私钥.
When a certificate is first imported or created, the private key must be marked as exportable in order for you to be able to export the private key.
您收到的错误消息表明您尝试使用的证书上的私钥不可导出.
The error message you have received indicates that the private key is not exportable on the certificate you are trying to use.
这篇关于Export-PfxCertificate:无法导出不可导出的私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!