Only log SSL Library version once

Move the 'fi' below the output, restore old behaviour.

Minor improvments to readability:
* Make "No Safe SSL config-file" the default.
  OpenSSL does not require a "Safe" config-file, only LibreSSL does.
  Change from $no_safe_ssl_conf to $require_safe_ssl_conf.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2022-04-25 22:56:28 +01:00
parent d199389217
commit a703f30e37
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -448,12 +448,9 @@ easyrsa_openssl() {
die "easyrsa_openssl - Failed to create temporary file"
fi
# OpenSSL does not need a safe config, skip this stage
if [ "$no_safe_ssl_conf" ]; then
cp -f "$EASYRSA_SSL_CONF" "$easyrsa_openssl_conf" || \
die "easyrsa_openssl - Failed to make temporary config"
else
# OpenSSL does not require a safe config, so skip to the copy
if [ "$require_safe_ssl_conf" ]; then
# Make a safe SSL config file
sed \
-e "s\`ENV::EASYRSA\`EASYRSA\`g" \
-e "s\`\$dir\`$EASYRSA_PKI\`g" \
@ -473,6 +470,10 @@ easyrsa_openssl() {
-e "s\`\$EASYRSA_REQ_EMAIL\`$EASYRSA_REQ_EMAIL\`g" \
"$EASYRSA_SSL_CONF" > "$easyrsa_openssl_conf" || \
die "easyrsa_openssl - Failed to make temporary config"
else
# Do NOT Make a safe SSL config file
cp -f "$EASYRSA_SSL_CONF" "$easyrsa_openssl_conf" || \
die "easyrsa_openssl - Failed to copy temporary config"
fi
if [ "$openssl_command" = "makesafeconf" ]; then
@ -543,25 +544,25 @@ verify_ssl_lib() {
val="$("$EASYRSA_OPENSSL" version)"
case "${val%% *}" in
# OpenSSL does not require a safe config-file
OpenSSL) no_safe_ssl_conf=1 ;;
LibreSSL) : ;; # ok
OpenSSL) unset -v require_safe_ssl_conf ;;
LibreSSL) require_safe_ssl_conf=1 ;;
*) die "\
Missing or invalid OpenSSL
Expected to find openssl command at: $EASYRSA_OPENSSL"
esac
fi
# Set SSL version dependent $no_password option
osslv_major="${val#* }"
osslv_major="${osslv_major%%.*}"
case "$osslv_major" in
1) no_password='-nodes' ;;
2) no_password='-nodes' ;; # LibreSSL Only
3) no_password='-noenc' ;;
*) die "Unsupported SSL library: $osslv_major"
esac
notice "Using SSL: $EASYRSA_OPENSSL $val"
EASYRSA_SSL_OK=1
# Set SSL version dependent $no_password option
osslv_major="${val#* }"
osslv_major="${osslv_major%%.*}"
case "$osslv_major" in
1) no_password='-nodes' ;;
2) no_password='-nodes' ;; # LibreSSL Only
3) no_password='-noenc' ;;
*) die "Unsupported SSL library: $osslv_major"
esac
notice "Using SSL: $EASYRSA_OPENSSL $val"
EASYRSA_SSL_OK=1
fi
# Verify EASYRSA_SSL_CONF file exists
[ -f "$EASYRSA_SSL_CONF" ] || die "\