revoke(): Purge unquoted $opts + General improvements
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
parent
3cff9494af
commit
fdcaf6cf79
@ -1385,19 +1385,27 @@ revoke() {
|
|||||||
verify_ca_init
|
verify_ca_init
|
||||||
|
|
||||||
# pull filename base:
|
# pull filename base:
|
||||||
[ -n "$1" ] || die "\
|
[ "$1" ] || die "\
|
||||||
Error: didn't find a file base name as the first argument.
|
Error: didn't find a file base name as the first argument.
|
||||||
Run easyrsa without commands for usage and command help."
|
Run easyrsa without commands for usage and command help."
|
||||||
crt_in="$EASYRSA_PKI/issued/$1.crt"
|
|
||||||
|
|
||||||
opts=""
|
# Assign file_name_base and dust off!
|
||||||
if [ "$2" ]; then
|
file_name_base="$1"
|
||||||
opts="$opts -crl_reason $2"
|
shift
|
||||||
|
crt_in="$EASYRSA_PKI/issued/$file_name_base.crt"
|
||||||
|
|
||||||
|
# Assign possible "crl_reason"
|
||||||
|
if [ "$1" ]; then
|
||||||
|
crl_reason="$1"
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
unset -v crl_reason
|
||||||
fi
|
fi
|
||||||
|
|
||||||
verify_file x509 "$crt_in" || die "\
|
# Enforce syntax
|
||||||
Unable to revoke as the input file is not a valid certificate. Unexpected
|
if [ "$1" ]; then
|
||||||
input in file: $crt_in"
|
die "Syntax error: $1"
|
||||||
|
fi
|
||||||
|
|
||||||
# confirm operation by displaying DN:
|
# confirm operation by displaying DN:
|
||||||
confirm "Continue with revocation: " "yes" "
|
confirm "Continue with revocation: " "yes" "
|
||||||
@ -1411,13 +1419,19 @@ $(display_dn x509 "$crt_in")
|
|||||||
Unable to revoke as no certificate was found. Certificate was expected
|
Unable to revoke as no certificate was found. Certificate was expected
|
||||||
at: $crt_in"
|
at: $crt_in"
|
||||||
|
|
||||||
# shellcheck disable=SC2086 # Ignore unquoted variables
|
# Verify certificate
|
||||||
easyrsa_openssl ca -utf8 -revoke "$crt_in" $opts \
|
verify_file x509 "$crt_in" || die "\
|
||||||
${EASYRSA_PASSIN:+-passin "$EASYRSA_PASSIN"} || die "\
|
Unable to revoke as the input file is not a valid certificate. Unexpected
|
||||||
Failed to revoke certificate: revocation command failed."
|
input in file: $crt_in"
|
||||||
|
|
||||||
|
# Revoke it
|
||||||
|
easyrsa_openssl ca -utf8 -revoke "$crt_in" \
|
||||||
|
${crl_reason+ -crl_reason "$crl_reason"} \
|
||||||
|
${EASYRSA_PASSIN:+ -passin "$EASYRSA_PASSIN"} \
|
||||||
|
|| die "Failed to revoke certificate: revocation command failed."
|
||||||
|
|
||||||
# move revoked files so we can reissue certificates with the same name
|
# move revoked files so we can reissue certificates with the same name
|
||||||
move_revoked "$1"
|
move_revoked "$file_name_base"
|
||||||
|
|
||||||
[ "$EASYRSA_SILENT" ] || print # Separate Notice below
|
[ "$EASYRSA_SILENT" ] || print # Separate Notice below
|
||||||
notice "\
|
notice "\
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user