Skip to content

Instantly share code, notes, and snippets.

@notbrain
Last active November 5, 2015 03:24
Show Gist options
  • Save notbrain/13668df681e3cb70a234 to your computer and use it in GitHub Desktop.
Save notbrain/13668df681e3cb70a234 to your computer and use it in GitHub Desktop.
Quick script for making self-signed certificates
#!/bin/sh
APP_NAME=$1
APPSSLPATH=/usr/local/etc/nginx/$APP_NAME;
sudo mkdir -p $APPSSLPATH && cd $APPSSLPATH;
sudo openssl req -new -newkey rsa:2048 -nodes -out $APP_NAME.csr -keyout $APP_NAME.key -subj "/C=US/ST=California/L=San Francisco/O=Engineering Inc./CN=$APP_NAME" && \
sudo /usr/bin/openssl x509 -req -days 1365 -in $APP_NAME.csr -signkey $APP_NAME.key -out $APP_NAME.crt;
echo "--"
echo "Use the following lines in nginx config:"
echo
echo "ssl_certificate_key $APPSSLPATH/$APP_NAME.key;"
echo "ssl_certificate $APPSSLPATH/$APP_NAME.crt;"
echo
echo "--"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment