From 0da9d5bc95cc2610cb881878812d0674e13b9630 Mon Sep 17 00:00:00 2001 From: Franz Schwartau Date: Fri, 15 Sep 2023 22:45:47 +0200 Subject: [PATCH] Add and use new variables $fullchain and $privkey --- fritzbox_upload_certificate.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fritzbox_upload_certificate.sh b/fritzbox_upload_certificate.sh index 7b15048..9d21aa2 100755 --- a/fritzbox_upload_certificate.sh +++ b/fritzbox_upload_certificate.sh @@ -105,11 +105,14 @@ done [ ${exit} -ne 0 ] && exit ${exit} -if [ ! -r "${certpath}/fullchain.pem" ] || [ ! -r "${certpath}/privkey.pem" ]; then +fullchain="${certpath}/fullchain.pem" +privkey="${certpath}/privkey.pem" + +if [ ! -r "${fullchain}" ] || [ ! -r "${privkey}" ]; then error "Certpath ${certpath} must contain fullchain.pem and privkey.pem" fi -if ! grep -q -- "-BEGIN RSA PRIVATE KEY-" "${certpath}/privkey.pem"; then +if ! grep -q -- "-BEGIN RSA PRIVATE KEY-" "${privkey}"; then error "FRITZ!OS only supports RSA private keys." fi @@ -129,7 +132,7 @@ if [ -z "${sid}" ] || [ "${sid}" = "0000000000000000" ]; then error "Login failed." fi -certbundle=$(cat "${certpath}/fullchain.pem" "${certpath}/privkey.pem" | grep -v '^$') +certbundle=$(cat "${fullchain}" "${privkey}" | grep -v '^$') # generate our upload request boundary="---------------------------$(date +%Y%m%d%H%M%S)"