Al *_*ath 1 powershell certificate
使用New-SelfSignedCertificate cmdlet,我要将硬盘上的位置指定为C:\ Development \ My Project。该命令:
New-SelfSignedCertificate -CertStoreLocation "cert:\LocalMachine\Development\My Project"
Run Code Online (Sandbox Code Playgroud)
给出此错误:
找不到路径“证书:\ LocalMachine \ Development \ My Project”,因为它不存在。
我该怎么做呢?
Run Code Online (Sandbox Code Playgroud)$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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4007 次 |
| 最近记录: |