diff --git a/azure-pipelines/templates/automation-cert-rhel.yml b/azure-pipelines/templates/automation-cert-rhel.yml new file mode 100644 index 00000000..a235be0c --- /dev/null +++ b/azure-pipelines/templates/automation-cert-rhel.yml @@ -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" diff --git a/azure-pipelines/templates/automation-cert.yml b/azure-pipelines/templates/automation-cert.yml index 1e1e7012..d545619d 100644 --- a/azure-pipelines/templates/automation-cert.yml +++ b/azure-pipelines/templates/automation-cert.yml @@ -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"