From 7afb52811982b4b04e59fc804d513bc505ff9099 Mon Sep 17 00:00:00 2001 From: Jansen Price Date: Wed, 26 Aug 2020 22:16:19 -0500 Subject: [PATCH] Add makecert utility --- bin/makecert | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 bin/makecert diff --git a/bin/makecert b/bin/makecert new file mode 100755 index 0000000..71ea051 --- /dev/null +++ b/bin/makecert @@ -0,0 +1,33 @@ +#!/bin/bash + +# Use this script to generate a self-signed cert for a given hostname +# Usage: bin/makecert [hostname] +# If you do not supply an argument, it will prompt for the hostname + +if [ -z $1 ]; then + read -p "Enter hostname: " hostname + HOSTNAME="$hostname" +else + HOSTNAME="$1" +fi + +HOSTNAME="${HOSTNAME//[ ]/-}" + +if [ -z "$HOSTNAME" ]; then + echo "Aborting..." + exit 1 +fi + +echo "Making cert and key for host '$HOSTNAME'" + +openssl req -x509 -newkey rsa:4096 -nodes\ + -days 365 -subj "/CN=$HOSTNAME"\ + -keyout "$HOSTNAME.key.pem"\ + -out "$HOSTNAME.cert.pem" + +# Use this one below with the -addext to include multiple domains (e.g. subdomains) +#openssl req -x509 -newkey rsa:4096 -nodes\ +# -days 365 -subj "/CN=$HOSTNAME"\ +# -keyout "$HOSTNAME.key.pem"\ +# -out "$HOSTNAME.cert.pem" +# -addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"