Skip to content

Instantly share code, notes, and snippets.

@liasica
Forked from jessedearing/gist:2351836
Last active February 20, 2017 02:49
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 liasica/a0189fe5a6d22cc2ed51981705a86d1d to your computer and use it in GitHub Desktop.
Save liasica/a0189fe5a6d22cc2ed51981705a86d1d to your computer and use it in GitHub Desktop.
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
rm myssl.key.org
echo "Generating certificate..."
openssl x509 -req -days 365 -in myssl.csr -signkey myssl.key -out myssl.crt
echo "Copying certificate (myssl.crt) to /etc/ssl/certs/"
mkdir -p /usr/local/etc/nginx/ssl/
cp myssl.crt /usr/local/etc/nginx/ssl/
echo "Copying key (myssl.key) to /etc/ssl/private/"
mkdir -p /usr/local/etc/nginx/ssl/
cp myssl.key /usr/local/etc/nginx/ssl/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment