#!/bin/bash
KEYLength=4096

echo -n "Name of the client certificate: "
read CLCERT
echo -n "Full path to your root CA file: "
read CACERT
echo -n "Full path to your root key file: "
read CAKEY
echo -n "Days of validity: "
read DAYS

openssl genrsa -out ${CLCERT}.key ${KEYLength}
openssl req -new -key ${CLCERT}.key -out ${CLCERT}.csr
openssl x509 -req -days $DAYS -CA ${CACERT} -CAkey ${CAKEY} -CAcreateserial -in ${CLCERT}.csr -out ${CLCERT}.crt
openssl pkcs12 -export -clcerts -in ${CLCERT}.crt -inkey ${CLCERT}.key -out ${CLCERT}.p12
echo "Client ${CLCERT}.p12 certificate created succesfully."

