Azure devops Azure devops pfx安装在远程vm中
我正在尝试在我的azure vm中安装pfx证书,并在变量组中保存了我的pfx文件,还保存了我的pfx密码。我正在使用下面的yaml脚本进行部署,但它不起作用。证书未安装在my azure远程vm中Azure devops Azure devops pfx安装在远程vm中,azure-devops,ssl-certificate,Azure Devops,Ssl Certificate,我正在尝试在我的azure vm中安装pfx证书,并在变量组中保存了我的pfx文件,还保存了我的pfx密码。我正在使用下面的yaml脚本进行部署,但它不起作用。证书未安装在my azure远程vm中 trigger: - master pool: vmImage: 'windows-latest' variables: - group: certificate-variable steps: - task: DownloadSecureFile@1 name: mySecureFile
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
- group: certificate-variable
steps:
- task: DownloadSecureFile@1
name: mySecureFile
displayName: 'Get the pfx file certificat'
inputs:
secureFile: '$(signingCert.secureFilePath)'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Host "Start adding the PFX file to the certificate store."
$pfxpath = '$(mySecureFile.secureFilePath)'
$password = '$(signingCert.password)'
Add-Type -AssemblyName System.Security
$cert =New-Object -TypeName
System.Security.Cryptography.X509Certificates.X509Certificate2($pfxpath, $password,
[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]PersistKeySet)
$store =New-object system.security.cryptography.X509Certificates.X509Store,CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]ReadWrite)
$store.Add($cert)
$store.Close()
您可以尝试这个powershell脚本
$pfxpath = '$(mySecureFile.secureFilePath)'
$password = '$(signingCert.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()
此外,我们还可以创建一个变量组,并添加一个名为sSecStrPassword的变量来保存密码,并添加power shell脚本来使用生成管道上使用的.pfx证书和下载安全文件任务。有关更多详细信息,请参阅此文档。此问题是否有更新?如果答案能给你一些帮助,请随时告诉我。只是提醒一下。谢谢。问题现在解决了。嗨@prabhu,很高兴听到你的问题已经解决了。如果下面的答案解决了您的问题,您可以作为答案,这样可以帮助其他社区成员解决同样的问题,我们可以存档此线程,谢谢。