Skip to content

Commit d971846

Browse files
committed
Implement --new-account-key and --DEACTIVATE-account
RFC operations for account security: --new-account-key replaces the account key with a new one. Can modify the type or size as well. (update .cfg first) Does not affect certificate validity or pending operations. --DEACTIVATE-account permanently deactivates the account on the server. Per RFC, can not be revived. Should not revoke existing certificates. (Server's choice.)
1 parent ab04ff4 commit d971846

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

README

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ domain(s) -X –experimental tag Allow upgrade to a specified version of
100100
getssl -U, –nocheck Do not check if a more recent version is available
101101
-v –version Display current version of getssl -w working_dir “Working
102102
directory” –preferred-chain “chain” Use an alternate chain for the
103-
certificate ```
103+
certificate --account-id Display account id and exit --new-account-key
104+
Replace the account key with a new one --DEACTIVATE-account
105+
Permanently deactivate account
106+
```
104107

105108

106109
Quick Start Guide

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ Options:
9393
-v --version Display current version of getssl
9494
-w working_dir "Working directory"
9595
--preferred-chain "chain" Use an alternate chain for the certificate
96+
--account-id Display account id and exit
97+
--new-account-key Replace the account key with a new one
98+
--DEACTIVATE-account Permanently deactivate account
9699
```
97100

98101
## Quick Start Guide

getssl

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
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)
294294
# 2024-03-17 Automatically update the ACCOUNT_EMAIL (#827) (tlhackque)
295+
# 2024-08-18 Implement --new-account-key and --DEACTIVATE-account (tlhackque)
295296
# ----------------------------------------------------------------------------------------
296297

297298
case :$SHELLOPTS: in
@@ -364,8 +365,10 @@ DNS_WAIT_RETRY_ADD="false" # Try the dns_add_command again if the DNS recor
364365
_CHECK_ALL=0
365366
_CREATE_CONFIG=0
366367
_CURL_VERSION=""
368+
_DEACTIVATE_ACCOUNT=0
367369
_FORCE_RENEW=0
368370
_MUTE=0
371+
_NEW_ACCOUNT_KEY=0
369372
_NOTIFY_VALID=0
370373
_NOMETER=""
371374
_QUIET=0
@@ -2079,6 +2082,8 @@ help_message() { # print out the help message
20792082
-w working_dir "Working directory"
20802083
--preferred-chain "chain" Use an alternate chain for the certificate
20812084
--account-id Display account id and exit
2085+
--new-account-key Replace the account key with a new one
2086+
--DEACTIVATE-account Permanently deactivate account
20822087
20832088
_EOF_
20842089
}
@@ -2326,11 +2331,13 @@ obtain_ca_resource_locations()
23262331
URL_new_reg=$(echo "$ca_all_loc" | grep "new-reg" | awk -F'"' '{print $4}')
23272332
URL_new_authz=$(echo "$ca_all_loc" | grep "new-authz" | awk -F'"' '{print $4}')
23282333
URL_new_cert=$(echo "$ca_all_loc" | grep "new-cert" | awk -F'"' '{print $4}')
2334+
URL_keyChange=$(echo "$ca_all_loc" | grep "key-change" | awk -F'"' '{print $4}')
23292335
#API v2
23302336
URL_newAccount=$(echo "$ca_all_loc" | grep "newAccount" | awk -F'"' '{print $4}')
23312337
URL_newNonce=$(echo "$ca_all_loc" | grep "newNonce" | awk -F'"' '{print $4}')
23322338
URL_newOrder=$(echo "$ca_all_loc" | grep "newOrder" | awk -F'"' '{print $4}')
23332339
URL_revoke=$(echo "$ca_all_loc" | grep "revokeCert" | awk -F'"' '{print $4}')
2340+
URL_keyChange=$(echo "$ca_all_loc" | grep "keyChange" | awk -F'"' '{print $4}')
23342341

23352342
if [[ -n "$URL_new_reg" ]] || [[ -n "$URL_newAccount" ]]; then
23362343
break
@@ -2708,7 +2715,7 @@ urlbase64_decode() {
27082715
usage() { # echos out the program usage
27092716
echo "Usage: $PROGNAME [-h|--help] [-d|--debug] [-c|--create] [-f|--force] [-a|--all] [-q|--quiet]"\
27102717
"[-Q|--mute] [-u|--upgrade] [-X|--experimental tag] [-U|--nocheck] [-r|--revoke cert key] [-w working_dir]"\
2711-
"[--preferred-chain chain] [--account-id] domain"
2718+
"[--preferred-chain chain] [--account-id] [--new-account-key] [--DEACTIVATE-account] domain"
27122719
}
27132720

27142721
write_domain_template() { # write out a template file for a domain.
@@ -2944,6 +2951,10 @@ while [[ -n ${1+defined} ]]; do
29442951
shift; PREFERRED_CHAIN="$1" ;;
29452952
--account-id)
29462953
_SHOW_ACCOUNT_ID=1 ;;
2954+
--new-account-key)
2955+
_NEW_ACCOUNT_KEY=1 ;;
2956+
--DEACTIVATE-account)
2957+
_DEACTIVATE_ACCOUNT=1 ;;
29472958
--source)
29482959
return ;;
29492960
-*)
@@ -3493,7 +3504,7 @@ elif [[ "$code" == '200' ]] ; then
34933504
if [[ "$code" == '200' ]]; then
34943505
info " - update succeeded"
34953506
else
3496-
info " - updaate failed"
3507+
info " - update failed"
34973508
fi
34983509
debug responseHeaders "$responseHeaders"
34993510
fi
@@ -3507,6 +3518,54 @@ if [[ ${_SHOW_ACCOUNT_ID} -eq 1 ]]; then
35073518
fi
35083519
# end of registering account with CA
35093520

3521+
# Current account key is OK, create a new one if requested
3522+
if [[ ${_NEW_ACCOUNT_KEY} == 1 ]]; then
3523+
info "creating a new ${ACCOUNT_KEY_TYPE} account key"
3524+
create_key "$ACCOUNT_KEY_TYPE" "${ACCOUNT_KEY}.new" "$ACCOUNT_KEY_LENGTH"
3525+
# Inner = old key, signed by new
3526+
inpay='{"account":"'"$KID"'","oldKey":'"$jwk"'}'
3527+
debug "Inner payload: $inpay"
3528+
inpay64="$(printf '%s' "$inpay" | urlbase64)"
3529+
get_signing_params "${ACCOUNT_KEY}.new"
3530+
inprot='{"alg": "'"$jwkalg"'", "jwk": '"$jwk"', "url":"'"$URL_keyChange"'"}'
3531+
debug "Inner protected: $inprot"
3532+
inprot64="$(printf '%s' "$inprot" | urlbase64)"
3533+
sign_string "$(printf '%s' "${inprot64}.${inpay64}")" "${ACCOUNT_KEY}.new" "$signalg"
3534+
inner='{"protected":"'"$inprot64"'","payload":"'"$inpay64"'","signature":"'"$signed64"'"}'
3535+
debug "Inner body: $inner"
3536+
# Outer = inner, signed by old
3537+
get_signing_params "${ACCOUNT_KEY}"
3538+
send_signed_request "$URL_keyChange" "$inner"
3539+
debug responseHeaders "$responseHeaders"
3540+
if [[ "$code" == '200' ]]; then
3541+
info " - update succeeded"
3542+
mv "${ACCOUNT_KEY}" "${ACCOUNT_KEY}.old"
3543+
mv "${ACCOUNT_KEY}.new" "${ACCOUNT_KEY}"
3544+
else
3545+
info " - update failed"
3546+
rm -f "${ACCOUNT_KEY}.new"
3547+
if [[ "$code" == '409' ]]; then
3548+
other=$(echo "$responseHeaders" | grep -i "^location" | awk '{print $2}'| tr -d '\r\n ')
3549+
error_exit "new key is in use by $other"
3550+
fi
3551+
fi
3552+
graceful_exit
3553+
fi
3554+
# end of new account key
3555+
3556+
# Permanently deactivate account
3557+
if [[ ${_DEACTIVATE_ACCOUNT} -eq 1 ]]; then
3558+
echo "PERMANENTLY deactivating account"
3559+
send_signed_request "$KID" '{"status":"deactivated"}'
3560+
if [[ "$code" == '200' ]]; then
3561+
info " - Account has been deactivated - it can NOT be revived"
3562+
else
3563+
info " - deactivation failed"
3564+
fi
3565+
debug responseHeaders "$responseHeaders"
3566+
fi
3567+
# end of deactivate account
3568+
35103569
# verify each domain
35113570
info "Verify each domain"
35123571

0 commit comments

Comments
 (0)