Skip to content

Instantly share code, notes, and snippets.

@edpichler
Forked from jessedearing/gist:2351836
Last active July 23, 2021 08:18
Show Gist options
  • Save edpichler/d7daa0c26b18dca6dc49f65f8d51274c to your computer and use it in GitHub Desktop.
Save edpichler/d7daa0c26b18dca6dc49f65f8d51274c to your computer and use it in GitHub Desktop.
Create a self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out private.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key private.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp private.key private.key.old
openssl rsa -in private.key.old -out private.key
rm private.key.old
echo "Generating certificate..."
openssl x509 -req -days 36500 -in myssl.csr -signkey private.key -out self-signed-public.crt
echo "Copying certificate (myssl.crt) to /etc/ssl/certs/"
mkdir -p /etc/ssl/certs
cp self-signed-public.crt /etc/ssl/certs/
echo "Copying key (myssl.key) to /etc/ssl/private/"
mkdir -p /etc/ssl/private
cp private.key /etc/ssl/private/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment