Browse Source

Merge pull request #2222 from dim0x69/master

Implement Update Account Information for ACMEv2
master
neil 6 years ago
committed by GitHub
parent
commit
c420a0ae2b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 60
      acme.sh

60
acme.sh

@ -3238,11 +3238,6 @@ _on_issue_success() {
} }
updateaccount() {
_initpath
_regAccount
}
registeraccount() { registeraccount() {
_reg_length="$1" _reg_length="$1"
_initpath _initpath
@ -3340,6 +3335,61 @@ _regAccount() {
_info "ACCOUNT_THUMBPRINT" "$ACCOUNT_THUMBPRINT" _info "ACCOUNT_THUMBPRINT" "$ACCOUNT_THUMBPRINT"
} }
#implement updateaccount
updateaccount() {
_initpath
if [ ! -f "$ACCOUNT_KEY_PATH" ] && [ -f "$_OLD_ACCOUNT_KEY" ]; then
_info "mv $_OLD_ACCOUNT_KEY to $ACCOUNT_KEY_PATH"
mv "$_OLD_ACCOUNT_KEY" "$ACCOUNT_KEY_PATH"
fi
if [ ! -f "$ACCOUNT_JSON_PATH" ] && [ -f "$_OLD_ACCOUNT_JSON" ]; then
_info "mv $_OLD_ACCOUNT_JSON to $ACCOUNT_JSON_PATH"
mv "$_OLD_ACCOUNT_JSON" "$ACCOUNT_JSON_PATH"
fi
if [ ! -f "$ACCOUNT_KEY_PATH" ]; then
_err "Account key is not found at: $ACCOUNT_KEY_PATH"
return 1
fi
_accUri=$(_readcaconf "ACCOUNT_URL")
_debug _accUri "$_accUri"
if [ -z "$_accUri" ]; then
_err "The account url is empty, please run '--update-account' first to update the account info first,"
_err "Then try again."
return 1
fi
if ! _calcjwk "$ACCOUNT_KEY_PATH"; then
return 1
fi
_initAPI
if [ "$ACME_VERSION" = "2" ]; then
if [ "$ACCOUNT_EMAIL" ]; then
updjson='{"contact": ["mailto: '$ACCOUNT_EMAIL'"]}'
fi
else
# ACMEv1: Updates happen the same way a registration is done.
# https://tools.ietf.org/html/draft-ietf-acme-acme-01#section-6.3
_regAccount
return
fi
# this part handles ACMEv2 account updates.
_send_signed_request "$_accUri" "$updjson"
if [ "$code" = '200' ]; then
_info "account update success for $_accUri."
else
_info "Error. The account was not updated."
return 1
fi
}
#Implement deactivate account #Implement deactivate account
deactivateaccount() { deactivateaccount() {
_initpath _initpath

Loading…
Cancel
Save