Add support for OpenSSL 3.x for creating DH parameter.

This commit is contained in:
2023-06-21 11:59:29 +02:00
parent 51da8fd016
commit 461a690939
2 changed files with 302 additions and 2 deletions

View File

@@ -135,6 +135,22 @@ blank_line() {
fi
}
get_openssl_version() {
OPENSSL_VERSION="$(openssl version|awk '{print $2}' | grep -o -E "[0-9]+\.[0-9]+\.[0-9]")"
OPENSSL_MAIN_VERSION=`echo $OPENSSL_VERSION | cut -d '.' -f1,2`
OPENSSL_MAJOR_VERSION=`echo $OPENSSL_VERSION | cut -d '.' -f1`
OPENSSL_MINOR_VERSION=`echo $OPENSSL_VERSION | cut -d '.' -f2`
OPENSSL_PATCH_LEVEL=`echo $OPENSSL_VERSION | cut -d '.' -f3`
if [[ -n "${OPENSSL_VERSION}" ]] ; then
return 0
else
return 1
fi
}
# ----------
@@ -230,10 +246,20 @@ done
blank_line
_failed=false
echononl "Generate a dhparam.pem file.."
if [[ -f "/etc/nginx/ssl/dhparam.pem" ]]; then
if [[ ${OPENSSL_MAJOR_VERSION} -gt 1 ]]; then
echononl "Generate a dhparam.pem file - \033[5m\033[1mmay take a lon time\033[m .."
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 > ${log_file} 2>&1
if [[ $? -ne 0 ]] ; then
echo_failed
error "$(cat $log_file)"
else
echo_ok
fi
elif [[ -f "/etc/nginx/ssl/dhparam.pem" ]]; then
echononl "Generate a dhparam.pem file .."
echo_skipped
else
echononl "Generate a dhparam.pem file with parameter '-dsaparam'.."
if [[ ! -d "/etc/nginx/ssl" ]] ; then
mkdir /etc/nginx/ssl > ${log_file} 2>&1
if [[ $? -ne 0 ]] ; then