使用 New-SelfSignedCertificate cmdlet,我想将硬盘驱动器上的位置指定为 C:\Development\My Project。这个命令:
New-SelfSignedCertificate -CertStoreLocation "cert:\LocalMachine\Development\My Project"
给出这个错误:
Cannot find path 'Cert:\LocalMachine\Development\My Project' because it does not exist.
我该怎么做呢?
$PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 5 0 10586 962
最佳答案
您为 New-SelfSignedCertificate -CertStoreLocation
指定的路径是证书存储区,而不是文件路径。您最有可能想要做的是指定 cert:\LocalMachine\my
这将在您的个人存储中创建证书,然后如果您需要以文件形式将该证书导出到硬盘驱动器上的文件中。这样的事情应该适用于:
$notAfter = [datetime]::Today.AddYears(2)
$thumb = (New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName $env:USERDNSDOMAIN -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $notAfter).Thumbprint
$pwd = 'SuperS3cret!'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
Export-PfxCertificate -cert "cert:\localmachine\my\$thumb" -FilePath "C:\Development\My Project\MyDevCert.pfx" -Password $SSpwd
关于powershell - New-SelfSignedCertificate -CertStoreLocation 找不到路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44763022/