Skip to content

Instantly share code, notes, and snippets.

@meson10
Created June 17, 2016 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meson10/7472e4fa2570f37ed3650594619eb925 to your computer and use it in GitHub Desktop.
Save meson10/7472e4fa2570f37ed3650594619eb925 to your computer and use it in GitHub Desktop.
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