Skip to content

Commit bb55c68

Browse files
committed
revoke: Replace duplicate file checks with specific command selection
Remove the checks for accidental use of 'revoke', when 'revoke-expired' or 'revoke-renewed' is intended. Replace these checks by forcing the user to decide which type of revoke command is required. When batch mode is enabled, assume that 'revoke' is intended. Signed-off-by: Richard T Bonhomme <[email protected]>
1 parent dff64e5 commit bb55c68

File tree

1 file changed

+12
-66
lines changed

1 file changed

+12
-66
lines changed

Diff for: easyrsa3/easyrsa

+12-66
Original file line numberDiff line numberDiff line change
@@ -3252,72 +3252,6 @@ Unable to revoke as the input-file is not a valid certificate.
32523252
Certificate was expected at:
32533253
* $crt_in"
32543254

3255-
# Check for misuse of revoke when revoke-* is intended
3256-
case "$cert_dir" in
3257-
issued)
3258-
# expired cert
3259-
exp_exist="${in_dir}/expired/${file_name_base}.crt"
3260-
if [ -f "$exp_exist" ]; then
3261-
exp_endd="$(
3262-
"$EASYRSA_OPENSSL" x509 -in "$exp_exist" -noout \
3263-
-enddate -serial)" || die "revoke - expire -enddate"
3264-
# shellcheck disable=SC2295 # Expansions inside ${..}
3265-
exp_confirm="
3266-
Expired certificate:
3267-
* $exp_exist
3268-
Expiry: ${exp_endd%%${NL}serial=*}
3269-
Serial: ${exp_endd##*serial=}
3270-
Use command 'revoke-expired' to revoke this certificate."
3271-
else
3272-
unset -v exp_exist exp_endd exp_confirm
3273-
fi
3274-
3275-
# renewed cert
3276-
ren_exist="${in_dir}/renewed/${file_name_base}.crt"
3277-
if [ -f "$ren_exist" ]; then
3278-
ren_endd="$(
3279-
"$EASYRSA_OPENSSL" x509 -in "$ren_exist" -noout \
3280-
-enddate -serial)" || die "revoke - renew -enddate"
3281-
# shellcheck disable=SC2295 # Expansions inside ${..}
3282-
ren_confirm="
3283-
Renewed certificate:
3284-
* $ren_exist
3285-
Expiry: ${ren_endd%%${NL}serial=*}
3286-
Serial: ${ren_endd##*serial=}
3287-
Use command 'revoke-renewed' to revoke this certificate."
3288-
else
3289-
unset -v ren_exist ren_endd ren_confirm
3290-
fi
3291-
3292-
# issued cert
3293-
crt_endd="$(
3294-
"$EASYRSA_OPENSSL" x509 -in "$crt_in" -noout \
3295-
-enddate -serial)" || die "revoke - expire -enddate"
3296-
3297-
# Confirm intended use of 'revoke'
3298-
if [ "$exp_exist" ] || [ "$ren_exist" ]; then
3299-
warn "The following certificate(s) exist:
3300-
${exp_exist:+${exp_confirm}${NL}}${ren_exist:+${ren_confirm}${NL}}"
3301-
# shellcheck disable=SC2295 # Expansions inside ${..}
3302-
confirm " Confirm intended use of 'revoke' ? " yes "\
3303-
Please confirm your intended use of 'revoke' for the following
3304-
issued certificate:${NL}
3305-
* $crt_in
3306-
Expiry: ${crt_endd%%${NL}serial=*}
3307-
Serial: ${crt_endd##*serial=}"
3308-
fi
3309-
3310-
# Revoking an issued cert forces req/key to be moved
3311-
move_req_and_key=1
3312-
;;
3313-
expired|renewed/issued)
3314-
# Revoke-expired/renewed cert means req/key can remain
3315-
move_req_and_key=
3316-
;;
3317-
*)
3318-
die "Invalid cert_dir: '$cert_dir'"
3319-
esac
3320-
33213255
# Verify request
33223256
if [ -f "$req_in" ]; then
33233257
verify_file req "$req_in" || user_error "\
@@ -3380,6 +3314,7 @@ The inline credentials files:
33803314
* $inline_pub
33813315
* $inline_pri"
33823316

3317+
# now confirm
33833318
confirm " Continue with revocation: " "yes" "
33843319
Please confirm that you wish to revoke the certificate
33853320
with the following subject:
@@ -5945,6 +5880,17 @@ case "$cmd" in
59455880
gen_crl
59465881
;;
59475882
revoke)
5883+
# Force user to select revoke type
5884+
[ "$EASYRSA_BATCH" ] || user_error "\
5885+
Please select which type of 'revoke' command is required:
5886+
* 'revoke-issued' will revoke a current certificate.
5887+
* 'revoke-expired' will revoke an old cert, which has been expired.
5888+
* 'revoke-renewed' will revoke an old cert, which has been renewed."
5889+
verify_working_env
5890+
cert_dir=issued
5891+
revoke "$@"
5892+
;;
5893+
revoke-issued)
59485894
verify_working_env
59495895
cert_dir=issued
59505896
revoke "$@"

0 commit comments

Comments
 (0)