Skip to content

Instantly share code, notes, and snippets.

@eresende
Created October 22, 2015 09:13
Show Gist options
  • Save eresende/2d073d0b8dcf468bf5b8 to your computer and use it in GitHub Desktop.
Save eresende/2d073d0b8dcf468bf5b8 to your computer and use it in GitHub Desktop.
Generate a wildcard SSL certificate
#!/usr/bin/env bash
# Specify where we will install
# the xip.io certificate
SSL_DIR="/etc/ssl/xip.io"
# Set the wildcarded domain
# we want to use
DOMAIN="*.xip.io"
# A blank passphrase
PASSPHRASE=""
# Set our CSR variables
SUBJ="
C=US
ST=Connecticut
O=
localityName=New Haven
commonName=$DOMAIN
organizationalUnitName=
emailAddress=
"
# Create our SSL directory
# in case it doesn't exist
sudo mkdir -p "$SSL_DIR"
# Generate our Private Key, CSR and Certificate
sudo openssl genrsa -out "$SSL_DIR/xip.io.key" 2048
sudo openssl req -new -subj "$(echo -n "$SUBJ" | tr "\n" "/")" -key "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.csr" -passin pass:$PASSPHRASE
sudo openssl x509 -req -days 365 -in "$SSL_DIR/xip.io.csr" -signkey "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.crt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment