Skip to content

Instantly share code, notes, and snippets.

@jjeaton
Created October 15, 2015 17:29
Show Gist options
  • Save jjeaton/b53e21a0740f663bc306 to your computer and use it in GitHub Desktop.
Save jjeaton/b53e21a0740f663bc306 to your computer and use it in GitHub Desktop.
Bash script to generate self-signed certificates for local dev.
#!/bin/sh
################################################################################
# Generates a self-signed certificate based on a domain name parameter
# Domain name should be the hostname and TLD only.
# Key and certificate will be output into the current working directory.
# This is useful for generating certificates to be used with VVV.
#
# @link https://github.com/Varying-Vagrant-Vagrants/VVV/wiki/Site-specific-self-signed-SSL-certificates
################################################################################
if [ "$#" -ne 1 ]
then
echo "Usage: create_ssl <example.com>"
exit 1
fi
openssl genrsa -out $1.key 2048
openssl req -new -x509 -key $1.key -out $1.cert -days 3650 -subj /CN=$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment