Skip to content

Instantly share code, notes, and snippets.

@gionn
Created September 26, 2013 19:43
Show Gist options
  • Save gionn/6719501 to your computer and use it in GitHub Desktop.
Save gionn/6719501 to your computer and use it in GitHub Desktop.
Simple script to generate a self-signed certificate for a domain (use *.domain.tld for a wildcard certificate) to be used on webserver (apache2, nginx).
#!/bin/bash
openssl genrsa 2048 > host.key
openssl req -new -x509 -nodes -sha1 -days 3650 -key host.key > host.cert
openssl x509 -noout -fingerprint -text < host.cert > host.info
cat host.cert host.key > host.pem
chmod 400 host.key host.pem
echo ## put on your nginx virtualhost ##
echo ssl on;
echo ssl_certificate /path/to/host.pem;
echo ssl_certificate_key /path/to/host.key;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment