#!/bin/bash CERTPATH="/etc/n4d/cert/" CERTNAME="n4d" if [ "$1" != "" ] ; then CERTPATH="$1" fi if [ ! -e "${CERTPATH}${CERTNAME}key.pem" ]; then if [ ! -e "${CERTPATH}${CERTNAME}.csr" ]; then mkdir -p $CERTPATH openssl genrsa -out ${CERTPATH}${CERTNAME}key.pem 2048 yes '' | openssl req -new -subj '/CN=n4d' -key ${CERTPATH}${CERTNAME}key.pem -out ${CERTPATH}${CERTNAME}.csr openssl x509 -req -days 6000 -in ${CERTPATH}${CERTNAME}.csr -signkey ${CERTPATH}${CERTNAME}key.pem -out ${CERTPATH}${CERTNAME}cert.pem fi fi