From 4880297e5c580e829e6e35d6e1fbc0844d68b5b9 Mon Sep 17 00:00:00 2001 From: David Mcanulty Date: Mon, 18 Apr 2016 15:26:21 -0700 Subject: [PATCH] Check return status of curl and report error This is really handy if you run without DEBUG mode and curl has a problem (like out of date SSL certs) --- acme.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/acme.sh b/acme.sh index 036dfe1e..e0b2bc87 100755 --- a/acme.sh +++ b/acme.sh @@ -491,8 +491,14 @@ _post() { CURL="$CURL --dump-header $HTTP_HEADER " if [ "$needbase64" ] ; then response="$($CURL -A "User-Agent: $USER_AGENT" -X POST --data "$body" $url | _base64)" + if [[ $? -gt 0 ]] ;then + _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + fi else response="$($CURL -A "User-Agent: $USER_AGENT" -X POST --data "$body" $url)" + if [[ $? -gt 0 ]] ;then + _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + fi fi else if [ "$needbase64" ] ; then @@ -514,8 +520,14 @@ _get() { if _exists "curl" ; then if [ "$onlyheader" ] ; then $CURL -I -A "User-Agent: $USER_AGENT" $url + if [[ $? -gt 0 ]] ;then + _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + fi else $CURL -A "User-Agent: $USER_AGENT" $url + if [[ $? -gt 0 ]] ;then + _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + fi fi else _debug "WGET" "$WGET"