diff --git a/docs/v1/versioned_docs/version-1.0.0-beta.14/Create-a-self-signed-SSL-certificate.md b/docs/v1/versioned_docs/version-1.0.0-beta.14/Create-a-self-signed-SSL-certificate.md index e22251fd9..c491699a4 100644 --- a/docs/v1/versioned_docs/version-1.0.0-beta.14/Create-a-self-signed-SSL-certificate.md +++ b/docs/v1/versioned_docs/version-1.0.0-beta.14/Create-a-self-signed-SSL-certificate.md @@ -14,6 +14,7 @@ brew install mkcert 2. Copy and paste the bash function into your terminal (or into your `.bashrc` file if you want to have it available in the future): +### Mac ```bash function ssl-check() { f=~/.localhost_ssl; @@ -62,6 +63,56 @@ function ssl-check() { } ``` +### Linux/Ubuntu +```bash +function ssl-check() { + f=~/.localhost_ssl; + ssl_crt=$f/server.crt + ssl_key=$f/server.key + b=$(tput bold) + c=$(tput sgr0) + + # gets all IPs returned by the hostname function + ips=$(hostname -I) + local_ips=($(echo $ips | tr " " "\n")) + # local_ip=999.999.999 # (uncomment for testing) + + domains=( + "localhost" + "${local_ips[@]}" + ) + + 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 + } +``` + 3. Run the function you just declared in step 2: ```bash