From: Lukas Schauer Date: Mon, 7 Dec 2015 11:08:30 +0000 (+0100) Subject: parse challenges json differently to be compatible with bsd sed X-Git-Tag: v0.1.0~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98a6c549ff1ee2d9626cb59d945d47ef688c6ae4;p=thirdparty%2Fdehydrated.git parse challenges json differently to be compatible with bsd sed --- 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})"