New-SelfSignedCertificate -CertStoreLocation找不到路径 [英] New-SelfSignedCertificate -CertStoreLocation cannot find path

查看:105
本文介绍了New-SelfSignedCertificate -CertStoreLocation找不到路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用New-SelfSignedCertificate cmdlet将硬盘上的位置指定为 C:\ Development \ My Project .此命令:

Using the New-SelfSignedCertificate cmdlet, I want to specify the location on my harddrive as C:\Development\My Project. This command:

New-SelfSignedCertificate -CertStoreLocation "cert:\LocalMachine\Development\My Project" 

给出此错误:

找不到路径证书:\ 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 ,它将在您的个人存储中创建证书,然后在需要时将该证书导出到硬盘驱动器上的文件中.文件形式.这样的事情应该适用于此:

The path that you specify for New-SelfSignedCertificate -CertStoreLocation is a certificate store, not a file path. What you will most likely want to do is specify cert:\LocalMachine\my which will create the certificate in your personal store, and then export that certificate to a file on the hard drive if you need it in file form. Something like this should work for that:

$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

这篇关于New-SelfSignedCertificate -CertStoreLocation找不到路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆