291
291
# 2023-02-22 Remove cronie from deb package dependencies (2.48)
292
292
# 2024-03-16 Use FTP_PORT when deleting ftp tokens. Delete tokens when using sftp, davfs, ftpes, ftps (#693,#839) (tlhackque)
293
293
# 2024 03-16 Fix dns-01's CNAME processing. (#840) (tlhackque)
294
+ # 2024-03-17 Automatically update the ACCOUNT_EMAIL (#827) (tlhackque)
294
295
# ----------------------------------------------------------------------------------------
295
296
296
297
case :$SHELLOPTS : in
@@ -3449,14 +3450,14 @@ info "Registering account"
3449
3450
# send the request to the ACME server.
3450
3451
if [[ $API -eq 1 ]]; then
3451
3452
if [[ " $ACCOUNT_EMAIL " ]] ; then
3452
- regjson=' {"resource": "new-reg", "contact": ["mailto: ' $ACCOUNT_EMAIL ' "], "agreement": "' $AGREEMENT ' "}'
3453
+ regjson=' {"resource": "new-reg", "contact": ["mailto:' $ACCOUNT_EMAIL ' "], "agreement": "' $AGREEMENT ' "}'
3453
3454
else
3454
3455
regjson=' {"resource": "new-reg", "agreement": "' $AGREEMENT ' "}'
3455
3456
fi
3456
3457
send_signed_request " $URL_new_reg " " $regjson "
3457
3458
elif [[ $API -eq 2 ]]; then
3458
3459
if [[ " $ACCOUNT_EMAIL " ]] ; then
3459
- regjson=' {"termsOfServiceAgreed": true, "contact": ["mailto: ' $ACCOUNT_EMAIL ' "]}'
3460
+ regjson=' {"termsOfServiceAgreed": true, "contact": ["mailto:' $ACCOUNT_EMAIL ' "]}'
3460
3461
else
3461
3462
regjson=' {"termsOfServiceAgreed": true}'
3462
3463
fi
@@ -3479,6 +3480,23 @@ elif [[ "$code" == '200' ]] ; then
3479
3480
KID=$( echo " $responseHeaders " | grep -i " ^location" | awk ' {print $2}' | tr -d ' \r\n ' )
3480
3481
debug responseHeaders " $responseHeaders "
3481
3482
debug " Already registered account, AccountId=${KID} "
3483
+ email=" $( json_get " $response " " contact" ) "
3484
+ if [[ " ${email# mailto: } " != " $ACCOUNT_EMAIL " ]]; then
3485
+ # Update account E-Mail (Note that a list is allowed by the RFC)
3486
+ if [[ -n " $ACCOUNT_EMAIL " ]]; then
3487
+ info " Updating account contact e-mail from '${email# mailto: } ' to '$ACCOUNT_EMAIL '"
3488
+ send_signed_request " $KID " ' {"contact": ["mailto:' $ACCOUNT_EMAIL ' "]}'
3489
+ else
3490
+ info " Removing account contact email '${email# mailto: } '"
3491
+ send_signed_request " $KID " ' {"contact": []}'
3492
+ fi
3493
+ if [[ " $code " == ' 200' ]]; then
3494
+ info " - update succeeded"
3495
+ else
3496
+ info " - updaate failed"
3497
+ fi
3498
+ debug responseHeaders " $responseHeaders "
3499
+ fi
3482
3500
else
3483
3501
error_exit " Error registering account ...$responseHeaders ... $( json_get " $response " detail) "
3484
3502
fi
0 commit comments