Skip to content
Snippets Groups Projects

Resolve "Include scripts to create client certificates in docker image"

1 file
+ 13
2
Compare changes
  • Side-by-side
  • Inline
#!/bin/bash
# Caciano Machado/Juliano Zatta - 16/10/2017
cd /certmanager
. config
openssl genpkey -algorithm RSA -out certificates/rootCA.key -pkeyopt rsa_keygen_bits:2048
openssl req -x509 -new -nodes -key certificates/rootCA.key -sha256 -days 3650 -out certificates/rootCA.pem -subj "/C=BR/ST=$STATE/L=$CITY/O=$ORG/OU=$UNIT/CN=$HOST" -set_serial "0x$(openssl rand -hex 8)"
\ No newline at end of file
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
\ No newline at end of file
Loading