Skip to content

Instantly share code, notes, and snippets.

@damienpontifex
Last active November 9, 2019 20:46
Show Gist options
  • Save damienpontifex/c0ff28081c0f202889bf697188822317 to your computer and use it in GitHub Desktop.
Save damienpontifex/c0ff28081c0f202889bf697188822317 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Map variables retrieved from Key Vault to environment variables such as:
# env:
# CERT_DATA: $(certData)
# CERT_PASSWORD: $(certPassword)
# Read in the PFX data and save as pfx file
echo "${CERT_DATA}" | base64 --decode > cert.pfx
# Extract out the certificate using the pfx password
openssl pkcs12 -nodes -nokeys -passin pass:"${CERT_PASSWORD}" -in cert.pfx -out cert.pem
# Extract out the private key using the pfx password
openssl pkcs12 -nodes -nocerts -passin pass:"${CERT_PASSWORD}" -in cert.pfx -out cert.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment