From 98a6c549ff1ee2d9626cb59d945d47ef688c6ae4 Mon Sep 17 00:00:00 2001 From: Lukas Schauer Date: Mon, 7 Dec 2015 12:08:30 +0100 Subject: [PATCH] parse challenges json differently to be compatible with bsd sed --- letsencrypt.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/letsencrypt.sh b/letsencrypt.sh index e7eac3c..804395c 100755 --- a/letsencrypt.sh +++ b/letsencrypt.sh @@ -140,8 +140,10 @@ sign_domain() { echo " + Requesting challenge for ${altname}..." response="$(signed_request "${CA}/acme/new-authz" '{"resource": "new-authz", "identifier": {"type": "dns", "value": "'"${altname}"'"}}')" - challenge_token="$(printf '%s\n' "${response}" | grep -Eo '"challenges":[^\[]*\[[^]]*]' | sed 's/{/\n{/g' | grep 'http-01' | grep -Eo '"token":\s*"[^"]*"' | cut -d'"' -f4 | sed 's/[^A-Za-z0-9_\-]/_/g')" - challenge_uri="$(printf '%s\n' "${response}" | grep -Eo '"challenges":[^\[]*\[[^]]*]' | sed 's/{/\n{/g' | grep 'http-01' | grep -Eo '"uri":\s*"[^"]*"' | cut -d'"' -f4)" + challenges="$(printf '%s\n' "${response}" | grep -Eo '"challenges":[^\[]*\[[^]]*]')" + challenge="$(printf "%s" "${challenges//\{/$'\n'{}" | grep 'http-01')" + challenge_token="$(printf '%s' "${challenge}" | grep -Eo '"token":\s*"[^"]*"' | cut -d'"' -f4 | sed 's/[^A-Za-z0-9_\-]/_/g')" + challenge_uri="$(printf '%s' "${challenge}" | grep -Eo '"uri":\s*"[^"]*"' | cut -d'"' -f4)" if [[ -z "${challenge_token}" ]] || [[ -z "${challenge_uri}" ]]; then echo " + Error: Can't retrieve challenges (${response})"