Hi Team,
I urgently need help. I am trying to install pfx certificate in my azure vm and saved my pfx file in variable group and saved my pfx password as well. I am using the below yaml script for deployment, but its not working. Certificate is not getting installed in my azure remote vm. please advise.
Starter pipeline
Start with a minimal pipeline that you can customize to build and deploy your code.
Add steps that build, run tests, deploy, and more:
https://aka.ms/yaml
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 -argumentlist "sakthi", CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$store.Add($cert)
$store.Close()