#!/usr/bin/env bash STATE=$(head -1 vars/state) COUNTRY=$(head -1 vars/country) LOCALITY=$(head -1 vars/locality) ORGANIZATION=$(head -1 vars/organization) LOCALITRY=$(head -1 vars/locality) CN=$(head -1 vars/cn) DAYS=$(head -1 vars/days) SUBJECT_ALTERNATIVES=$( python3 gen-subject-alternatives.py ) jinja2 templates/csrconfig.txt.j2 -D cn="${CN}" -D country="${COUNTRY}" -D state="${STATE}" -D locality="${LOCALITY}" \ -D org="${ORGANIZATION}" -D subj_alternative="${SUBJECT_ALTERNATIVES}" > tmp/csrconfig.txt #generate the RSA private key openssl genpkey -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out output/priv.key #Create the CSR openssl req -new -nodes -key output/priv.key -config tmp/csrconfig.txt -out output/cert.csr # Generate the self-signed certificate openssl x509 -req -days ${DAYS} -in output/cert.csr -signkey output/priv.key -out output/cert.pem