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

Ale*_*nko 13 powershell code-signing certificate pfx visual-studio-2017

我尝试通过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"
Run Code Online (Sandbox Code Playgroud)

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

VS2017密码请求

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

VS2017拒绝密码

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

UPDATE

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

spo*_*yno 0

这对你有用吗?

& certutil -v -privatekey certificate.pfx | ? {$_ -match "^PFX protected password: ""(?<password>.*)""$"} | % { $matches.password }
Run Code Online (Sandbox Code Playgroud)