web/bin/create-ca

17 lines
425 B
Text
Raw Normal View History

2016-04-05 00:19:21 +00:00
#!/usr/bin/env bash
BASEDIR=$(realpath $(dirname $0));
KEYDIR=$(realpath "$BASEDIR/../storage/ca/");
2016-06-12 17:48:33 +00:00
if [ -f "$KEYDIR/ca.key" ]; then
2016-04-05 00:19:21 +00:00
echo "CA key already exists. not overwriting it."
exit 1;
fi
CN="ob.ae-cn";
if [ ! -z "$1" ]; then
2016-06-12 17:48:33 +00:00
CN="$1";
2016-04-05 00:19:21 +00:00
fi;
2016-06-12 17:48:33 +00:00
openssl req -days 3650 -nodes -new -x509 -keyout "$KEYDIR/ca.key" -out "$KEYDIR/ca.crt" -subj "/CN=$CN" -extensions ca_ext -config "$BASEDIR/../etc/openssl.conf";