Skip to content

Instantly share code, notes, and snippets.

@antho1404
Created January 26, 2015 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antho1404/e0f80fae41cdb77b5582 to your computer and use it in GitHub Desktop.
Save antho1404/e0f80fae41cdb77b5582 to your computer and use it in GitHub Desktop.
generate a ssl certificate, combine it and add it to a heroku app
if [ $1 = "create" ]
then
brew update
brew upgrade openssl
openssl genrsa -des3 -out server.pass.key 2048
openssl rsa -in server.pass.key -out server.key
openssl req -nodes -new -key server.key -out server.csr
echo ''
cat server.csr
cat server.csr | pbcopy
echo ''
echo '======================================='
echo 'Paste this key to configure your certificate in your Godaddy or whatever account (already in your clipboard ;) )'
echo '======================================='
fi
if [ $1 = "publish" ]
then
crt=$2
bundle=$3
echo "Combine cerfificates"
cat $crt $bundle > combined.crt
echo "Choose your heroku app"
read app
status=$(heroku apps | grep -E "$app( |$)")
if [ $? -ne 0 ]
then
heroku apps:create $app
fi
heroku addons:add ssl:endpoint -a $app
heroku certs:add combined.crt server.key -a $app
heroku certs -a $app
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment