-
Rodrigo Goncalves authoredRodrigo Goncalves authored
create-ca.sh 608 B
#!/bin/bash
# Caciano Machado/Juliano Zatta - 16/10/2017
cd /certmanager
. config
cd certificates
if [ -a ${CERTNAME}.pem ]; then
echo "WARNING: Certificate with name $CERTNAME already exists."
echo "WARNING: If you really want to delete it then do it manually."
else
ROOTCA_SERIAL=`openssl rand -hex 8`
openssl genrsa -out ${CERTNAME}.key $KEYSIZE
openssl req -subj "/C=BR/ST=$STATE/L=$CITY/O=$ORG/OU=$UNIT/CN=Root\ Certificate" -x509 -new -nodes -key ${CERTNAME}.key -sha256 -days $ROOTEXP -out ${CERTNAME}.pem -set_serial "0x$ROOTCA_SERIAL"
echo $ROOTCA_SERIAL > rootCA.srl
fi