Created
June 17, 2016 08:26
-
-
Save meson10/7472e4fa2570f37ed3650594619eb925 to your computer and use it in GitHub Desktop.
Service to coordinate with Azure API and idempotently upload certificates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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