@@ -34,7 +34,6 @@ encode_base64() {
3434
3535# Let's Encrypt v2 curl function
3636query_le_v2 () {
37-
3837 protected=' {"nonce": "' $3 ' ",'
3938 protected=' ' $protected ' "url": "' $1 ' ",'
4039 protected=' ' $protected ' "alg": "RS256", "kid": "' $KID ' "}'
@@ -50,7 +49,10 @@ query_le_v2() {
5049 post_data=$post_data ' "payload":"' " $payload_ " ' ",'
5150 post_data=$post_data ' "signature":"' " $signature_ " ' "}'
5251
53- curl -s -i -d " $post_data " " $1 " -H " $content "
52+ # Save http response to file passed as "$4" arg or print to stdout if not provided
53+ # http response headers are always sent to stdout
54+ local save_to_file=${4:- " /dev/stdout" }
55+ curl --silent --dump-header /dev/stdout --data " $post_data " " $1 " --header " $content " --output " $save_to_file "
5456}
5557
5658
@@ -358,7 +360,11 @@ if [[ "$status" -ne 200 ]]; then
358360fi
359361
360362# Downloading signed certificate / STEP 7
361- curl -s " $certificate " -o $ssl_dir /$domain .pem
363+ answer= $( query_le_v2 " $certificate " " " " $nonce " " $ssl_dir /$domain .pem" )
364+ status= $( echo " $answer " | grep HTTP/ | tail -n1 | cut -f 2 -d ' ' )
365+ if [[ " $status " -ne 200 ]]; then
366+ check_result $E_NOTEXIST " Let's Encrypt downloading signed cert failed status:$status "
367+ fi
362368
363369# Splitting up downloaded pem
364370crt_end= $( grep -n END $ssl_dir /$domain .pem | head -n1 | cut -f1 -d:)
0 commit comments