我通过以下方式使用 Visual Studio 开发人员命令提示符创建了 PFX 证书;
makecert -r -pe -n "CN=mycert" -sky exchange "mycert.cer" -sv "mycert.pvk"
pvk2pfx -pvk "mycert.pvk" -spc "mycert.cer" -pfx "mycert.pfx" -pi [password]
Run Code Online (Sandbox Code Playgroud)
然后我使用 PowerShell 来查询证书
$cert = Get-PfxCertificate [Location]
$cert.Verify()
# Returns 'False'
Run Code Online (Sandbox Code Playgroud)
如何获得此证书以用于加密?
@root 建议使用Import-PfxCertificate命令。这是我运行它时发生的情况。
Import-PfxCertificate -FilePath [Path]
Import-PfxCertificate : The PFX file you are trying to import requires either a different password or membership in an Active Directory principal to which it is protected.
At line:1 char:1
+ Import-PfxCertificate -FilePath [...]
+ …Run Code Online (Sandbox Code Playgroud)