域保护的pfx需要什么密码?

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

我尝试通过PowerShell创建一个自签名代码签名证书,通过Visual Studio 2017签署.NET程序集,然后将其作为pfx。使用-ProtectTo参数将pfx导出为受域保护的证书。代码如下:

$pfxLocation = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("Desktop"),"Certificates\")
New-Item -ItemType Directory -Path $pfxLocation -Force
$certificate = New-SelfSignedCertificate `
               -CertStoreLocation "Cert:\LocalMachine" `
               -FriendlyName "This is a code-signing certificate" `
               -Subject "CN=Me" `
               -Type CodeSigningCert `
               -NotBefore ([System.DateTime]::Today) `
               -NotAfter ([System.DateTime]::Today.AddMonths(6).AddDays(1)) `
               -KeyExportPolicy Exportable
Move-Item -Destination "Cert:\LocalMachine\Root" -Path $certificate.PSPath
$newCertificateLocation = "Cert:\LocalMachine\Root\" + $certificate.Thumbprint
Get-ChildItem $newCertificateLocation | Export-PfxCertificate -FilePath ([System.IO.Path]::Combine($pfxLocation,"certificate.pfx")) -ProtectTo "Domain\Domain group 1", "Domain\Domain group 2"

但是,Visual Studio仍然需要一个不存在的密码。

VS2017 password request

来自使用-ProtectTo参数指定的域组之一的域用户的密码被拒绝:

VS2017 rejects password

那么它要求什么密码,为什么它要求任何密码呢?由于它受域保护,它不应该有任何,这正是我的目标。

UPDATE

基本上,我们的想法是使用输出pfx与自动构建代理进行代码签名,因为缺少密码是必须的。

powershell visual-studio-2017 certificate code-signing pfx
1个回答
0
投票

这对你有用吗?

& certutil -v -privatekey certificate.pfx | ? {$_ -match "^PFX protected password: ""(?<password>.*)""$"} | % { $matches.password }
© www.soinside.com 2019 - 2024. All rights reserved.