Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions azure-pipelines/templates/automation-cert-rhel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# File: automation-cert.yml

steps:
- task: AzureKeyVault@2
displayName: 'Azure Key Vault: Download Cert for Automation'
inputs:
azureSubscription: 'AuthSdkResourceManager'
KeyVaultName: 'msidlabs'
SecretsFilter: 'LabAuth'

- task: Bash@3
displayName: Install Automation Cert
inputs:
targetType: inline
script: |
echo "Decoding and exporting certificate"

# Decode base64 encoded certificate
kvSecretBytes=$(echo "$(LabAuth)" | tr -d '\r' | base64 -d)

# Write decoded bytes to a temporary file
echo "$kvSecretBytes" > LabAuth.pem

# Export certificate to PKCS#12 format
openssl pkcs12 -export -out LabAuth.pfx -inkey LabAuth.pem -in LabAuth.pem -passout pass:


# Verify the certificate file creation
if [ -f "$(Build.SourcesDirectory)/LabAuth.pfx" ]; then
echo "The needed PFX file created successfully at $(Build.SourcesDirectory)/LabAuth.pfx"
else
echo "Failed to create the needed PFX file at $(Build.SourcesDirectory)/LabAuth.pfx"
exit 1
fi

# Set the certificate path as an environment variable for later steps
certPathVar=$(Build.SourcesDirectory)/LabAuth.pfx
echo "##vso[task.setvariable variable=LabVaultAppCert]$certPathVar"
echo "##vso[task.setvariable variable=LabVaultAppCert;isOutput=true]$certPathVar"
2 changes: 1 addition & 1 deletion azure-pipelines/templates/automation-cert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ steps:
Write-Error "Failed to create PFX file at $certPathVar"
}

Write-Host "##vso[task.setvariable variable=LabVaultAppCert]$certPathVar"
Write-Host "##vso[task.setvariable variable=LabVaultAppCert;isOutput=true]$certPathVar"