Created
September 4, 2015 10:30
-
-
Save tomfun/02a3022299a54685354b to your computer and use it in GitHub Desktop.
generate ssl certificate/wildcard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# https://serversforhackers.com/self-signed-ssl-certificates | |
# http://stackoverflow.com/questions/7580508/getting-chrome-to-accept-self-signed-localhost-certificate | |
# Specify where we will install | |
# the xip.io certificate | |
SSL_DIR="/home/tomfun/prj/ssl/o.o" | |
SSL_FILE="o.o" | |
# Set the wildcarded domain | |
# we want to use | |
DOMAIN="*.o.o" | |
# A blank passphrase | |
PASSPHRASE="" | |
# Set our CSR variables | |
SUBJ=" | |
C=UA | |
ST=None | |
O= | |
localityName=Kharkiv | |
commonName=$DOMAIN | |
organizationalUnitName= | |
[email protected] | |
" | |
# 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_FILE.key" 2048 | |
openssl req -new -subj "$(echo -n "$SUBJ" | tr "\n" "/")" -key "$SSL_DIR/$SSL_FILE.key" -out "$SSL_DIR/$SSL_FILE.csr" -passin pass:$PASSPHRASE | |
openssl x509 -req -days 768 -in "$SSL_DIR/$SSL_FILE.csr" -signkey "$SSL_DIR/$SSL_FILE.key" -out "$SSL_DIR/$SSL_FILE.crt" | |
echo "remember passphrase, it will asked for in browser" | |
openssl pkcs12 -export -out "$SSL_DIR/$SSL_FILE.p12" -inkey "$SSL_DIR/$SSL_FILE.key" -in "$SSL_DIR/$SSL_FILE.crt" -certfile "$SSL_DIR/$SSL_FILE.crt" | |
ls -lA "$SSL_DIR" | |
echo -e "\n Add\n$SSL_DIR/$SSL_FILE.p12\n to your browser\n" | |
echo "Copy to nginx..." | |
sudo cp "$SSL_DIR/$SSL_FILE.crt" /etc/ssl/certs/ | |
sudo cp "$SSL_DIR/$SSL_FILE.key" /etc/ssl/private/ | |
echo "http://joxi.ru/gmvjOyYFPDP0ma http://joxi.ru/Vm6kz8aHaYa82Z" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nginx: