From c4d8fd83d446ab53161d4310f3b6157037b62a24 Mon Sep 17 00:00:00 2001 From: neil Date: Tue, 31 May 2016 20:32:58 +0800 Subject: [PATCH] check return code --- acme.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/acme.sh b/acme.sh index c3d9d76f..8f9bc65a 100755 --- a/acme.sh +++ b/acme.sh @@ -1242,7 +1242,13 @@ issue() { vtype="$VTYPE_DNS" fi _info "Getting token for domain" $d - _send_signed_request "$API/acme/new-authz" "{\"resource\": \"new-authz\", \"identifier\": {\"type\": \"dns\", \"value\": \"$d\"}}" + + if ! _send_signed_request "$API/acme/new-authz" "{\"resource\": \"new-authz\", \"identifier\": {\"type\": \"dns\", \"value\": \"$d\"}}" ; then + _err "Can not get domain token." + _clearup + return 1 + fi + if [ ! -z "$code" ] && [ ! "$code" = '201' ] ; then _err "new-authz error: $response" _clearup @@ -1419,7 +1425,12 @@ issue() { fi fi - _send_signed_request $uri "{\"resource\": \"challenge\", \"keyAuthorization\": \"$keyauthorization\"}" + if ! _send_signed_request $uri "{\"resource\": \"challenge\", \"keyAuthorization\": \"$keyauthorization\"}" ; then + _err "$d:Can not get challenge: $response" + _clearupwebbroot "$_currentRoot" "$removelevel" "$token" + _clearup + return 1 + fi if [ ! -z "$code" ] && [ ! "$code" = '202' ] ; then _err "$d:Challenge error: $response" @@ -1494,7 +1505,11 @@ issue() { _clearup _info "Verify finished, start to sign." der="$(_getfile "${CSR_PATH}" "${BEGIN_CSR}" "${END_CSR}" | tr -d "\r\n" | _urlencode)" - _send_signed_request "$API/acme/new-cert" "{\"resource\": \"new-cert\", \"csr\": \"$der\"}" "needbase64" + + if ! _send_signed_request "$API/acme/new-cert" "{\"resource\": \"new-cert\", \"csr\": \"$der\"}" "needbase64" ; then + _err "Sign failed." + return 1 + fi Le_LinkCert="$(grep -i -o '^Location.*$' $HTTP_HEADER | head -1 | tr -d "\r\n" | cut -d " " -f 2)"