TrustedPublishers 的新自签名证书不起作用

问题描述 投票:0回答:1

在带有 Powershell 的 Windows 10 上,我尝试使用以下命令直接在 TrustedPublishers 存储中创建自签名证书:

New-SelfSignedCertificate -Subject 'ABC' -CertStoreLocation Cert:\LocalMachine\TrustedPublishers

但是我收到错误:

New-SelfSignedCertificate : Cannot find path 'Cert:\LocalMachine\TrustedPublishers' because it does not exist.
At line:1 char:2
+  New-SelfSignedCertificate -Subject 'B0014' -CertStoreLocation Cert:\ ...
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Cert:\LocalMachine\TrustedPublishers:String) [New-SelfSignedCertificate
   ], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.CertificateServices.Commands.NewSelfSignedCertificateCommand

但是 LocalMachine\TrustedPublishers 商店似乎存在:

enter image description here

如何直接在 TrustedPublishers 商店中创建自签名证书?

powershell windows-10 x509certificate
1个回答
0
投票

文档显示参数 -CertStoreLocation 声明它不支持除

cert:\LocalMachine
cert:\CurrentUser', or 
My`

之外的任何其他商店
-CertStoreLocation [<String>]
    Specifies the certificate store in which to store the new certificate.  If the current path is
    Cert:\CurrentUser or Cert:\CurrentUser\My, the default store is Cert:\CurrentUser\My. If the current path is
    Cert:\LocalMachine or Cert:\LocalMachine\My, the default store is Cert:\LocalMachine\My. Otherwise, you must
    specify Cert:\CurrentUser\My or Cert:\LocalMachine\My for this parameter. This parameter does not support
    other certificate stores.

即使您将位置设置为商店并尝试制作证书,您也会收到错误

Set-Location Cert:\LocalMachine\TrustedPublisher\
New-SelfSignedCertificate -Subject 'ABC'

错误

New-SelfSignedCertificate : A new certificate can only be installed into MY store.
At line:1 char:1
+ New-SelfSignedCertificate -Subject 'ABC'

但是,您可以简单地在允许的存储之一中创建证书并移动它。

Set-Location Cert:\LocalMachine\My\
New-SelfSignedCertificate -Subject 'ABC'

Get-Childitem . | Where-Object subject -like '*abc' | Foreach-Object {
    Move-Item -Path $_.pspath -Destination cert:\LocalMachine\TrustedPublisher\
}
© www.soinside.com 2019 - 2024. All rights reserved.