verify_ssl_lib(): Minor style improvements

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2023-07-05 22:26:40 +01:00
parent ac0d826272
commit 91bb2cf8e9
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -1120,32 +1120,33 @@ ${has_config:+-config $easyrsa_safe_ssl_conf }$*"
# and establish version dependencies # and establish version dependencies
verify_ssl_lib() { verify_ssl_lib() {
# Run once only # Run once only
[ "$EASYRSA_SSL_OK" ] && die "verify_ssl_lib - Overloaded" [ "$verify_ssl_lib_ok" ] && return
EASYRSA_SSL_OK=1 verify_ssl_lib_ok=1
# redirect std-err to ignore missing etc/ssl/openssl.cnf file # redirect std-err, ignore missing ssl/openssl.cnf
val="$("$EASYRSA_OPENSSL" version 2>/dev/null)" val="$("$EASYRSA_OPENSSL" version 2>/dev/null)"
ssl_version="$val"
# SSL lib name # SSL lib name
require_safe_ssl_conf=1
case "${val%% *}" in case "${val%% *}" in
# OpenSSL does require a safe config-file for ampersand # OpenSSL does require a safe config-file for ampersand
OpenSSL) OpenSSL)
ssl_lib=openssl ssl_lib=openssl
if [ -z "$EASYRSA_NO_SAFE_SSL" ]; then if [ "$EASYRSA_NO_SAFE_SSL" ]; then
require_safe_ssl_conf=1 unset -v require_safe_ssl_conf
fi fi
;; ;;
LibreSSL) LibreSSL)
ssl_lib=libressl ssl_lib=libressl
require_safe_ssl_conf=1 if [ "$EASYRSA_NO_SAFE_SSL" ]; then
if [ "$EASYRSA_NO_SAFE_SSL" ]; then
user_error \
"Cannot use '--no-safe-ssl' with LibreSSL"
fi
;;
*)
error_msg="$("$EASYRSA_OPENSSL" version 2>&1)"
user_error "\ user_error "\
Cannot use '--no-safe-ssl' with LibreSSL"
fi
;;
*)
error_msg="$("$EASYRSA_OPENSSL" version 2>&1)"
user_error "\
* OpenSSL must either exist in your PATH * OpenSSL must either exist in your PATH
or be defined in your vars file. or be defined in your vars file.
@ -1158,20 +1159,17 @@ $error_msg"
osslv_major="${val#* }" osslv_major="${val#* }"
osslv_major="${osslv_major%%.*}" osslv_major="${osslv_major%%.*}"
case "$osslv_major" in case "$osslv_major" in
1) no_password='-nodes' ;; 1) no_password='-nodes' ;;
2) no_password='-nodes' ;; 2) no_password='-nodes' ;;
3) 3)
case "$ssl_lib" in case "$ssl_lib" in
openssl) no_password='-noenc' ;; openssl) no_password='-noenc' ;;
libressl) no_password='-nodes' ;; libressl) no_password='-nodes' ;;
*) user_error \ *) die "Unexpected SSL library: $ssl_lib"
"Unsupported SSL library: $ssl_lib" esac
esac ;;
;; *) die "Unexpected SSL version: $osslv_major"
*) user_error "Unsupported SSL library: $osslv_major"
esac esac
ssl_version="$val"
} # => verify_ssl_lib() } # => verify_ssl_lib()
# Basic sanity-check of PKI init and complain if missing # Basic sanity-check of PKI init and complain if missing
@ -1301,7 +1299,7 @@ and initialize a fresh PKI here."
do do
# # # shellcheck disable=SC2115 # Use "${var:?}" # # # shellcheck disable=SC2115 # Use "${var:?}"
target="$EASYRSA_PKI/$i" target="$EASYRSA_PKI/$i"
if [ "${#target}" -gt 1 ]; then if [ "${target%/*}" ]; then
rm -rf "$target" || \ rm -rf "$target" || \
die "init-pki soft reset(1) failed!" die "init-pki soft reset(1) failed!"
else else
@ -6476,6 +6474,7 @@ detect_host
# Initialisation requirements # Initialisation requirements
unset -v \ unset -v \
verify_ssl_lib_ok \
easyrsa_error_exit \ easyrsa_error_exit \
prohibit_no_pass \ prohibit_no_pass \
secured_session \ secured_session \