#!/usr/bin/env bash # Runs ON the server inside ~/projects/ap-pilot: generates secrets (never printed) and test certificates. set -euo pipefail cd "$(dirname "$0")" if [ ! -f .env ]; then umask 077 cat > .env </dev/null for pair in "ok:30" "crit:5"; do n=${pair%%:*}; d=${pair##*:} openssl req -newkey rsa:2048 -nodes -keyout $n.key -out $n.csr -subj "/CN=tls.pilot" 2>/dev/null printf "subjectAltName=DNS:tls.pilot\n" > $n.ext openssl x509 -req -in $n.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out $n.pem -days $d -extfile $n.ext 2>/dev/null done chmod 644 *.pem; chmod 600 *.key; rm -f *.csr *.ext fi echo "setup ok"