gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 06:21:23 26 4
gpt4 key购买 nike

我尝试通过 powershell 创建自签名代码签名证书,然后通过 Visual Studio 2017 将其作为 pfx 签署 .NET 程序集。使用 -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

那么它请求什么密码以及为什么它需要任何密码?由于它受域名保护,因此不应该有任何内容,而这正是我的目标。

更新

基本上,这个想法是使用输出pfx通过自动构建代理进行代码签名,为此必须不需要密码。

最佳答案

此导出 PFX 无需密码。通过 GUI 导入时,可以使用空密码。

$cert = @(Get-ChildItem -Path 'Cert:\CurrentUser\My\07BAE0886EECC2019F0AE6CC68FE5C3EA98308F8')[0]
$certBytes = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx)
[System.IO.File]::WriteAllBytes('S:\cert.pfx', $certBytes)

关于powershell - 受域保护的 pfx 需要什么密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51498409/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com