Browse Source

check return code

neil 9 years ago
parent
commit
c4d8fd83d4
1 changed files with 18 additions and 3 deletions
  1. 18 3
      acme.sh

+ 18 - 3
acme.sh

@@ -1242,7 +1242,13 @@ issue() {
         vtype="$VTYPE_DNS"
         vtype="$VTYPE_DNS"
       fi
       fi
       _info "Getting token for domain" $d
       _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
       if [ ! -z "$code" ] && [ ! "$code" = '201' ] ; then
         _err "new-authz error: $response"
         _err "new-authz error: $response"
         _clearup
         _clearup
@@ -1419,7 +1425,12 @@ issue() {
       fi
       fi
     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
     if [ ! -z "$code" ] && [ ! "$code" = '202' ] ; then
       _err "$d:Challenge error: $response"
       _err "$d:Challenge error: $response"
@@ -1494,7 +1505,11 @@ issue() {
   _clearup
   _clearup
   _info "Verify finished, start to sign."
   _info "Verify finished, start to sign."
   der="$(_getfile "${CSR_PATH}" "${BEGIN_CSR}" "${END_CSR}" | tr -d "\r\n" | _urlencode)"
   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)"
   Le_LinkCert="$(grep -i -o '^Location.*$' $HTTP_HEADER | head -1 | tr -d "\r\n" | cut -d " " -f 2)"