Skip to content

Instantly share code, notes, and snippets.

@wolph
Last active August 25, 2020 19:21
Show Gist options
  • Save wolph/f959c2beccdd0fae925c to your computer and use it in GitHub Desktop.
Save wolph/f959c2beccdd0fae925c to your computer and use it in GitHub Desktop.
Easily whitelisting SSL certificates in Chrome under OS X
#!/usr/bin/env bash -e
HOST=$(echo "$1" | sed -E -e 's/https?:\/\///' -e 's/\/.*//')
if [[ "$HOST" =~ .*\..* ]]; then
echo "Adding certificate for $HOST"
echo -n | openssl s_client -connect $HOST:443 -servername $HOST \
| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' \
| tee "/tmp/$HOST.cert"
sudo security add-trusted-cert -d -r trustRoot \
-k "/Library/Keychains/System.keychain" "/tmp/$HOST.cert"
rm -v "/tmp/$HOST.cert"
else
echo "Usage: $0 www.site.name"
echo "http:// and such will be stripped automatically"
fi
@wolph
Copy link
Author

wolph commented May 2, 2015

This version includes SNI support :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment