291291# 2023-02-22 Remove cronie from deb package dependencies (2.48)
292292# 2024-03-16 Use FTP_PORT when deleting ftp tokens. Delete tokens when using sftp, davfs, ftpes, ftps (#693,#839) (tlhackque)
293293# 2024 03-16 Fix dns-01's CNAME processing. (#840) (tlhackque)
294+ # 2024-03-17 Automatically update the ACCOUNT_EMAIL (#827) (tlhackque)
294295# ----------------------------------------------------------------------------------------
295296
296297case :$SHELLOPTS : in
@@ -3449,14 +3450,14 @@ info "Registering account"
34493450# send the request to the ACME server.
34503451if [[ $API -eq 1 ]]; then
34513452 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 ' "}'
34533454 else
34543455 regjson=' {"resource": "new-reg", "agreement": "' $AGREEMENT ' "}'
34553456 fi
34563457 send_signed_request " $URL_new_reg " " $regjson "
34573458elif [[ $API -eq 2 ]]; then
34583459 if [[ " $ACCOUNT_EMAIL " ]] ; then
3459- regjson=' {"termsOfServiceAgreed": true, "contact": ["mailto: ' $ACCOUNT_EMAIL ' "]}'
3460+ regjson=' {"termsOfServiceAgreed": true, "contact": ["mailto:' $ACCOUNT_EMAIL ' "]}'
34603461 else
34613462 regjson=' {"termsOfServiceAgreed": true}'
34623463 fi
@@ -3479,6 +3480,23 @@ elif [[ "$code" == '200' ]] ; then
34793480 KID=$( echo " $responseHeaders " | grep -i " ^location" | awk ' {print $2}' | tr -d ' \r\n ' )
34803481 debug responseHeaders " $responseHeaders "
34813482 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
34823500else
34833501 error_exit " Error registering account ...$responseHeaders ... $( json_get " $response " detail) "
34843502fi
0 commit comments