Skip to content

Instantly share code, notes, and snippets.

@s4parke
Created March 1, 2016 22:57
Show Gist options
  • Save s4parke/678dbfc174fba8f52c51 to your computer and use it in GitHub Desktop.
Save s4parke/678dbfc174fba8f52c51 to your computer and use it in GitHub Desktop.
Script to generate a self-signed SSL wildcard certificate
#!/usr/bin/env bash
# Specify where we will install
# the ssl certificate
SSL_DIR="secrets"
# Set the wildcarded domain
# we want to use
DOMAIN="*.uvabht.org"
# A blank passphrase
PASSPHRASE=""
# Set our CSR variables
SUBJ="
C=US
ST=Virginia
O=
localityName=Charlottesville
commonName=$DOMAIN
organizationalUnitName=
emailAddress=
"
# Create our SSL directory
# in case it doesn't exist
mkdir -p "$SSL_DIR"
# Generate our Private Key, CSR and Certificate
openssl genrsa -out "$SSL_DIR/ssl.key" 2048
openssl req -new -subj "$(echo -n "$SUBJ" | tr "\n" "/")" -key "$SSL_DIR/ssl.key" -out "$SSL_DIR/ssl.csr" -passin pass:$PASSPHRASE
openssl x509 -req -days 365 -in "$SSL_DIR/ssl.csr" -signkey "$SSL_DIR/ssl.key" -out "$SSL_DIR/ssl.crt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment