From d8fca69d5ff1e9d675970386ea447f1391c33bf3 Mon Sep 17 00:00:00 2001 From: srvrco Date: Thu, 22 Sep 2016 10:09:07 +0100 Subject: [PATCH] added additional checks and retry on 500 error from ACME server --- getssl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/getssl b/getssl index f8f7766..9bb39b3 100755 --- a/getssl +++ b/getssl @@ -107,11 +107,12 @@ # 2016-09-19 remove update check on recursive calls when using -a (1.41) # 2016-09-21 changed shebang for portability (1.42) # 2016-09-21 Included option to Deactivate an Authorization (1.43) -# 2016-09-21 retry on 500 error from ACME server (1.44) +# 2016-09-22 retry on 500 error from ACME server (1.44) +# 2016-09-22 added additional checks and retry on 500 error from ACME server (1.45) # --------------------------------------------------------------------------- PROGNAME=${0##*/} -VERSION="1.44" +VERSION="1.45" # defaults CODE_LOCATION="https://raw.githubusercontent.com/srvrco/getssl/master/getssl" @@ -505,7 +506,8 @@ send_signed_request() { # Sends a request to the ACME server, signed with your p body='{"header": '"${header}"', "protected": "'"${protected64}"'", "payload": "'"${payload64}"'", "signature": "'"${signed64}"'"}' debug "data for account registration = $body" - code=500 + code="500" + loop_limit=5 while [ $code -eq 500 ]; do if [ "$needbase64" ] ; then response=$($CURL -X POST --data "$body" "$url" | urlbase64) @@ -519,8 +521,13 @@ send_signed_request() { # Sends a request to the ACME server, signed with your p code=$(os_grep ^HTTP "$CURL_HEADER" | tail -1 | cut -d " " -f 2) debug code "$code" response_status=$(echo "$response"| os_grep status | head -1 | awk -F'"' '{print $4}') - if [ $code -eq 500 ]; then - info "error on acme server - trying again" + if [ "$code" -eq 500 ]; then + info "error on acme server - trying again ...." + sleep 2 + loop_limit=$((loop_limit - 1)) + if [ $loop_limit -lt 1 ]; then + error_exit "500 error from ACME server: $response" + fi fi done }