Skip to content

Instantly share code, notes, and snippets.

@arashm
Last active June 23, 2017 18:28
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 arashm/345855107b19276bc67e8a56126d89f2 to your computer and use it in GitHub Desktop.
Save arashm/345855107b19276bc67e8a56126d89f2 to your computer and use it in GitHub Desktop.
Make self signed SSL certificate
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out certificate.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key certificate.key -out certificate.csr
echo "Removing passphrase from key (for nginx)..."
cp -v certificate.{key,org}
openssl rsa -in certificate.org -out certificate.key
rm certificate.org
echo "Generating certificate..."
openssl x509 -sha256 -req -days 365 -in certificate.csr -signkey certificate.key -out certificate.crt
## You may choose other paths for storing your certificates
echo "Copying certificate (certificate.crt) to /etc/ssl/certs/"
mkdir -p /etc/ssl/certs
cp certificate.crt /etc/ssl/certs/
echo "Copying key (certificate.key) to /etc/ssl/private/"
mkdir -p /etc/ssl/private
cp certificate.key /etc/ssl/private/
# If usign nginx, then include these in your `server` block:
#
# ssl on;
# ssl_certificate /etc/ssl/certs/certificate.crt;
# ssl_certificate_key /etc/ssl/private/certificate.key;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment