Files
pki.sh/sign-inter.sh

26 lines
545 B
Bash
Executable File

#!/bin/sh
while getopts ":hn:a:d:" opt; do
case $opt in
h)
echo "Usage: -n <name> -a <CA authority> -d <days>"
exit 0
;;
n)
NAME_OPT=(-in "$OPTARG".csr -out "$OPTARG".crt)
;;
a)
AUTHORITY_OPT=(-CA $OPTARG.crt -CAkey $OPTARG.key)
;;
d)
DAYS_OPT="-days $OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
openssl x509 -req -sha256 $DAYS_OPT "${NAME_OPT[@]}" "${AUTHORITY_OPT[@]}" -extfile pki.cnf -extensions v3_intermediate_ca