Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created August 16, 2013 14:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevenharman/6250508 to your computer and use it in GitHub Desktop.
Save stevenharman/6250508 to your computer and use it in GitHub Desktop.
Generate a self-signed cert, update your hosts file, and add it to your OS X Keychain for local SSL success!
#!/usr/bin/env sh
echo "Creating a self-signed certificate..."
openssl req -new -newkey rsa:2048 -sha1 -days 3650 -nodes -x509 -subj "/C=US/ST=Georgia/L=Atlanta/O=BNR/CN=localhost.ssl" -keyout config/server.key -out config/server.crt
if ! grep -q "\blocalhost\.ssl\b" /private/etc/hosts; then
echo "Adding localhost.ssl to your hosts file..."
echo "127.0.0.1 localhost.ssl" | sudo tee -a /private/etc/hosts
fi
printf "\e[36m"
echo ""
echo "-------------------------------------"
echo "Some manual setup steps are required:"
echo ""
echo "Add server.crt as trusted SYSTEM (not login)"
echo " cert in the mac osx keychain"
echo "1) Open keychain tool"
echo "2) Drag .crt file to the 'System' Keychain"
echo "3) Trust everything @_@"
printf "\e[0m"
open config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment