如何在Visual Studio Online Teamservices中注册/加载.pfx证书以用于持续集成?

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

我目前正在使用PowerShell通过Connect-AzureAD与证书和SPN连接到Azure AD。这是我的脚本的一部分,我创建一个自签名证书,导出到我的机器上的本地商店,然后加载它:

$thumb = (New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName com.foo.bar -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $notAfter).Thumbprint
$pwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
Export-PfxCertificate -cert "cert:\localmachine\my\$thumb" -FilePath $certPath -Password $pwd

# Load the certificate
$cert  = New-Object System.Security.Cryptography.X509Certificates.X509Certificate($certPath, $pwd)
$keyValue = [System.Convert]::ToBase64String($cert.GetRawCertData())

问题是如何在VSTS Online中使用类似的PowerShell脚本执行此操作?还有这样的证书商店吗?我已经有一个我需要使用的.pfx,不需要创建一个新的.pfx。

powershell azure certificate azure-devops azure-pipelines
1个回答
0
投票

请参阅此线程以将pfx文件导入到store:Visual studio team services deploymen/buildt certificate error

  $pfxpath = 'pathtoees.pfx'
    $password = 'password'

    Add-Type -AssemblyName System.Security
    $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
    $cert.Import($pfxpath, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet")
    $store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser
    $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
    $store.Add($cert)
    $store.Close()
© www.soinside.com 2019 - 2024. All rights reserved.