From aab55d0d91b00ef1dc4a4346c748edc911e3d9b6 Mon Sep 17 00:00:00 2001 From: nicholas Date: Fri, 28 Jan 2022 20:18:59 +0000 Subject: [PATCH] commit issue.sh --- .../certificates/internal/manios.ca/issue.sh | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 automation/certificates/internal/manios.ca/issue.sh diff --git a/automation/certificates/internal/manios.ca/issue.sh b/automation/certificates/internal/manios.ca/issue.sh new file mode 100644 index 0000000..0730169 --- /dev/null +++ b/automation/certificates/internal/manios.ca/issue.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# loop through the directories +for hostDir in */ ; do + echo "Entering ${hostDir}"; + + # get the current CAs + (cd "${hostDir}" && sscep getca -f issue.cnf); + + # if there is a cert present, then we likely want to renew + if test -f "${hostDir}/crt.pem"; then + echo "Cert already exists in ${hostDir}crt.pem, do you mean to renew?"; + else + echo "Issuing certificate in ${hostDir}"; + + # generate a new key and csr + (cd "${hostDir}" && ./gen.sh); + + # make the cert issue request + (cd "${hostDir}" && sscep enroll -f issue.cnf); + + # make a full chain cert file + (cd "${hostDir}" && cat crt.pem ca.pem-1 ca.pem-2 > fullchain.pem); + + echo "Copying the current cert to the 'prev' directory for future renews"; + + # copy this cert +key into the prev folder + (cd "${hostDir}" && cp crt.pem prev/crt.pem && cp key.pem prev/key.pem); + fi; +done;