view make-certificate @ 35:5697821137de

Revert graph changes after fixing value ordering Backed out changeset 6e30e90527d6
author IBBoard <dev@ibboard.co.uk>
date Sat, 27 Feb 2021 15:57:46 +0000
parents 86ca8ee7b597
children
line wrap: on
line source

#! /bin/bash

set -e

if [ $# -ne 1 -a $# -ne 2 ]; then
	echo "Usage: $0 <key-name> [<alt-name>]"
	exit 1
fi

if [ ! -d ~/Websites/certs/ ]; then
	echo "~/Websites/certs/ didn't exist - can't create certs"
	exit 1
fi

if [ $# -eq 2 ]; then
	extra="\nDNS.2=$2"
else
	extra=""
fi

pushd ~/Websites/certs/

openssl req -nodes -sha256 -new -keyout $1.key -out $1.csr -subj "/C=GB/ST=Worcestershire/O=$1/CN=$1" \
	-config <(cat ~/.ssh/CA/openssl.cnf <(echo -e "DNS.1=${1}${extra}"))
openssl ca -in $1.csr -out $1.crt -cert ~/.ssh/CA/ca.crt -keyfile ~/.ssh/CA/ca.key -days 365 \
	-config <(cat ~/.ssh/CA/openssl.cnf <(echo -e "DNS.1=${1}${extra}")) -batch
popd