Last active
October 18, 2016 16:19
-
-
Save samdfonseca/aabc718377566892c0bf4afa34047587 to your computer and use it in GitHub Desktop.
Whitelist self-signed certs on OS X
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
#!/usr/bin/env bash -e | |
SERVERNAME=$(echo "$1" | sed -E -e 's/https?:\/\///' -e 's/\/.*//') | |
echo "$SERVERNAME" | |
if [[ "$SERVERNAME" =~ .*\..* ]]; then | |
echo "Adding certificate for $SERVERNAME" | |
echo -n | openssl s_client -connect $SERVERNAME:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | tee /tmp/$SERVERNAME.cert | |
sudo security add-trusted-cert -d -r trustRoot -k "$HOME/Library/Keychains/login.keychain" /tmp/$SERVERNAME.cert | |
else | |
echo "Usage: $0 www.site.name" | |
echo "http:// and such will be stripped automatically" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment