Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Service to coordinate with Azure API and idempotently upload certificates
#!/bin/sh
set -e
service=$1
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
output="${DIR}/ssh_thumbprint"
cd $DIR
if [[ `azure service cert list | grep -c $service` -eq 0 ]]; then
$service="domain-gamma"
openssl req -x509 \
-key $service-deployer.key \
-nodes \
-days 1365 -newkey rsa:2048 \
-out /tmp/$service-deployer.pem \
-subj ‘/CN=domain.com/O=Domain Inc./C=US’
openssl x509 \
-outform der \
-in /tmp/$service-deployer.pem \
-out /tmp/$service-deployer.pfx
azure service cert create $service /tmp/$service-deployer.pfx
fi
azure service cert list | \
grep $service | \
awk '{print $3}' | \
tr -d '\n' > $output
rm -f /tmp/$service-deployer.{pem,pfx}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment