Skip to content

Instantly share code, notes, and snippets.

@mfigueroa
Created November 8, 2018 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfigueroa/90f4d256921c3d8923101198a1ad2f89 to your computer and use it in GitHub Desktop.
Save mfigueroa/90f4d256921c3d8923101198a1ad2f89 to your computer and use it in GitHub Desktop.
SSL Check for Windows
function ssl-check() {
f=~/.localhost_ssl;
ssl_crt=$f/server.crt
ssl_key=$f/server.key
b=$(tput bold)
c=$(tput sgr0)
local_ip=YOUR_LOCAL_IP
domains=(
"localhost"
"$local_ip"
)
if [[ ! -f $ssl_crt ]]; then
echo -e "\n🛑 ${b}Couldn't find a Slate SSL certificate:${c}"
make_key=true
elif [[ ! $(openssl x509 -noout -text -in $ssl_crt | grep $local_ip) ]]; then
echo -e "\n🛑 ${b}Your IP Address has changed:${c}"
make_key=true
else
echo -e "\n✅ ${b}Your IP address is still the same.${c}"
fi
if [[ $make_key == true ]]; then
echo -e "Generating a new Slate SSL certificate...\n"
count=$(( ${#domains[@]} - 1))
mkcert ${domains[@]}
# Create Slate's default certificate directory, if it doesn't exist
test ! -d $f && mkdir $f
# It appears mkcert bases its filenames off the number of domains passed after the first one.
# This script predicts that filename, so it can copy it to Slate's default location.
if [[ $count = 0 ]]; then
mv ./localhost.pem $ssl_crt
mv ./localhost-key.pem $ssl_key
else
mv ./localhost+$count.pem $ssl_crt
mv ./localhost+$count-key.pem $ssl_key
fi
fi
}
ssl-check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment