Skip to content

Commit

Permalink
Merge pull request #16 from franzs/refactor_variables_for_certificate…
Browse files Browse the repository at this point in the history
…_components

Add and use new variables $fullchain and $privkey
  • Loading branch information
franzs authored Sep 15, 2023
2 parents e3b7fc7 + 0da9d5b commit 8ae9ed9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fritzbox_upload_certificate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)"
Expand Down

0 comments on commit 8ae9ed9

Please sign in to comment.