Refactor manual CA passphrase input

This is a personal preference only. No functional change.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2023-01-04 00:28:50 +00:00
parent 7c9f18bfb8
commit e27ab41dad
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -1261,16 +1261,16 @@ Could not disable echo. Password will be shown on screen!"
get_passphrase() { get_passphrase() {
while :; do while :; do
r="" r=""
printf '\n%s' "$prompt" t="$1"; shift || die "password malfunction"
printf '\n%s' "$*"
hide_read_pass r hide_read_pass r
if [ "${#r}" -lt 4 ]; then if [ "${#r}" -lt 4 ]; then
printf '\n%s\n' \ printf '\n%s\n' \
"Passphrase must be at least 4 characters!" "Passphrase must be at least 4 characters!"
else else
safe_set_var "$*" "$r" || \ safe_set_var "$t" "$r" || die "Passphrase error!"
die "Passphrase error!" unset -v r t
unset -v r
print print
return 0 return 0
fi fi
@ -1405,12 +1405,12 @@ Please update openssl-easyrsa.cnf to the latest official release."
p="" p=""
q="" q=""
# Get passphrase p # Get passphrase p
prompt="Enter New CA Key Passphrase: " get_passphrase p \
get_passphrase p "Enter New CA Key Passphrase: "
# Confirm passphrase q # Confirm passphrase q
prompt="Confirm New CA Key Passphrase: " get_passphrase q \
get_passphrase q "Confirm New CA Key Passphrase: "
fi fi
# Validate passphrase # Validate passphrase