Created
February 11, 2017 10:26
-
-
Save v6ak/ab9c98256ce47c4d489288a979fdca5f to your computer and use it in GitHub Desktop.
Extracts cert from Sandstorm JSON file and skips trust anchor (the root CA)
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/bash | |
. /opt/sandstorm/sandstorm.conf # Well, no one except root can write the file, so it is probably acceptable to execute it. | |
certjsonfile=$(ls "/opt/sandstorm/var/sandcats/https/$SANDCATS_HOSTNAME/"*.response-json | sort -r -n | head -n1) | |
keyfile=$(sed 's/\.response-json$//' <<< "$certjsonfile") | |
certfile="$keyfile.crt" | |
cat "$certjsonfile" | jq '.cert, (.ca|.[1:]|reverse)[]' --raw-output > "$certfile" | |
ln -sfT "$certfile" "/etc/current-certs/$SANDCATS_HOSTNAME.crt" | |
ln -sfT "$keyfile" "/etc/current-certs/$SANDCATS_HOSTNAME.key" | |
sudo systemctl reload nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment