diff options
Diffstat (limited to 'dehydrated/share/hooks')
-rwxr-xr-x | dehydrated/share/hooks/deploy_cert.extra | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/dehydrated/share/hooks/deploy_cert.extra b/dehydrated/share/hooks/deploy_cert.extra index fd93fad..b0d8737 100755 --- a/dehydrated/share/hooks/deploy_cert.extra +++ b/dehydrated/share/hooks/deploy_cert.extra @@ -27,12 +27,14 @@ DIRECTORY="$(dirname "${CERTFILE}")" if [ "$(grep -c 'BEGIN CERTIFICATE' ${FULLCHAINFILE})" -ge 3 ] then - # - chain.pem: R3 | ISRG Root X1 - # - fullchain.pem: Certificate | R3 | ISRG Root X1 + # long chain: + # * chain.pem: (R3 | ISRG Root X1) + # * fullchain.pem: (Certificate | R3 | ISRG Root X1) CHAIN="long" else - # - chain.pem: R3 - # - fullchain.pem: Certificate | R3 + # short chain: + # * chain.pem: (R3) + # * fullchain.pem (Certificate | R3) CHAIN="short" fi @@ -53,7 +55,7 @@ case "${CHAIN}" in short) # intermediate (R3) - cp "${DIRECTORY}/chain-${TIMESTAMP}.pem" "${DIRECTORY}/intermediate-${TIMESTAMP}.pem" + grep -Ev '^$' "${DIRECTORY}/chain-${TIMESTAMP}.pem" > "${DIRECTORY}/intermediate-${TIMESTAMP}.pem" ln -sf "${DIRECTORY}/intermediate-${TIMESTAMP}.pem" "${DIRECTORY}/intermediate.pem" # root (ISRG Root X1) @@ -68,14 +70,19 @@ case "${CHAIN}" in esac # extra certificate permutations: -# * privkey_fullchain.pem: postfix -for EXTRA in fullchain_privkey privkey_fullchain +# * privkey_fullchain.pem: postfix +# * root_intermediate_cert.pem: redis + +for EXTRA in fullchain_privkey privkey_fullchain root_intermediate_cert do - EXTRA1="$(echo ${EXTRA} | awk -F_ '{ print $1 }')" - EXTRA2="$(echo ${EXTRA} | awk -F_ '{ print $2 }')" + rm -f "${DIRECTORY}/${EXTRA}-${TIMESTAMP}.pem" + + for FILE in $(echo ${EXTRA} | sed -e 's|_| |g') + do + cat "${DIRECTORY}/${FILE}-${TIMESTAMP}.pem" >> "${DIRECTORY}/${EXTRA}-${TIMESTAMP}.pem" + done - cat "${DIRECTORY}/${EXTRA1}-${TIMESTAMP}.pem" "${DIRECTORY}/${EXTRA2}-${TIMESTAMP}.pem" > "${DIRECTORY}/${EXTRA1}_${EXTRA2}-${TIMESTAMP}.pem" - ln -sf "${EXTRA1}_${EXTRA2}-${TIMESTAMP}.pem" "${DIRECTORY}/${EXTRA1}_${EXTRA2}.pem" + ln -sf "${EXTRA}-${TIMESTAMP}.pem" "${DIRECTORY}/${EXTRA}.pem" done echo " done." |