Skip to content

Commit de9c2cb

Browse files
committed
[LE api-v2] Do not use unauth GET when downloading certs
LE staging api has dropped unauth GET and only accepts POST-AS-GET since 05 dec 2019 https://community.letsencrypt.org/t/acme-v2-scheduled-deprecation-of-unauthenticated-resource-gets/74380
1 parent d9e983b commit de9c2cb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bin/v-add-letsencrypt-domain

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ encode_base64() {
3434

3535
# Let's Encrypt v2 curl function
3636
query_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
358360
fi
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
364370
crt_end=$(grep -n END $ssl_dir/$domain.pem |head -n1 |cut -f1 -d:)

0 commit comments

Comments
 (0)