@@ -20472,7 +20472,7 @@ find_openssl_binary() {
2047220472 local s_client_starttls_has=$TEMPDIR/s_client_starttls_has.txt
2047320473 local s_client_starttls_has2=$TEMPDIR/s_client_starttls_has2
2047420474 local openssl_location="" cwd=""
20475- local curve=""
20475+ local curve="" ossl_tls13_supported_curves
2047620476 local ossl_line1="" yr=""
2047720477 local -a curves_ossl=("sect163k1" "sect163r1" "sect163r2" "sect193r1" "sect193r2" "sect233k1" "sect233r1" "sect239k1" "sect283k1" "sect283r1" "sect409k1" "sect409r1" "sect571k1" "sect571r1" "secp160k1" "secp160r1" "secp160r2" "secp192k1" "prime192v1" "secp224k1" "secp224r1" "secp256k1" "prime256v1" "secp384r1" "secp521r1" "brainpoolP256r1" "brainpoolP384r1" "brainpoolP512r1" "X25519" "X448" "brainpoolP256r1tls13" "brainpoolP384r1tls13" "brainpoolP512r1tls13" "ffdhe2048" "ffdhe3072" "ffdhe4096" "ffdhe6144" "ffdhe8192")
2047820478
@@ -20665,26 +20665,42 @@ find_openssl_binary() {
2066520665 fi
2066620666 fi
2066720667
20668- if $OPENSSL s_client -curves </dev/null 2>&1 | grep -aiq "unknown option"; then
20669- if $OPENSSL s_client -groups </dev/null 2>&1 | grep -aiq "unknown option"; then
20670- # this is for openssl versions like 0.9.8, they do not have -groups or -curves -- just to be safe
20671- :
20668+ if [[ ! "$OSSL_NAME" =~ LibreSSL ]] && [[ $OSSL_VER_MAJOR -gt 3 || $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 3.[5-9]* ]]; then
20669+ OSSL_SUPPORTED_CURVES="$($OPENSSL list -tls1_2 -tls-groups)"
20670+ if [[ -n "$OSSL_SUPPORTED_CURVES" ]]; then
20671+ OSSL_SUPPORTED_CURVES=" ${OSSL_SUPPORTED_CURVES//:/ } "
20672+ ossl_tls13_supported_curves="$($OPENSSL list -tls1_3 -tls-groups)"
20673+ for curve in ${ossl_tls13_supported_curves//:/ }; do
20674+ [[ ! "$OSSL_SUPPORTED_CURVES" =~ \ $curve\ ]] && OSSL_SUPPORTED_CURVES+="$curve "
20675+ done
20676+ OSSL_SUPPORTED_CURVES="${OSSL_SUPPORTED_CURVES//secp192r1/prime192v1}"
20677+ OSSL_SUPPORTED_CURVES="${OSSL_SUPPORTED_CURVES//secp256r1/prime256v1}"
20678+ OSSL_SUPPORTED_CURVES="${OSSL_SUPPORTED_CURVES//x25519/X25519}"
20679+ OSSL_SUPPORTED_CURVES="${OSSL_SUPPORTED_CURVES//x448/X448}"
20680+ fi
20681+ fi
20682+ if [[ -z "$OSSL_SUPPORTED_CURVES" ]]; then
20683+ if $OPENSSL s_client -curves </dev/null 2>&1 | grep -aiq "unknown option"; then
20684+ if $OPENSSL s_client -groups </dev/null 2>&1 | grep -aiq "unknown option"; then
20685+ # this is for openssl versions like 0.9.8, they do not have -groups or -curves -- just to be safe
20686+ :
20687+ else
20688+ # LibreSSL (tested with version 3.4.1 and 3.0.2) need -groups instead of -curve
20689+ # WSL users connect to "127.0.0.1:0", others to "invalid." or "invalid.:0"
20690+ # The $OPENSSL connect call deliberately fails: when the curve isn't available with the described error messages
20691+ for curve in "${curves_ossl[@]}"; do
20692+ $OPENSSL s_client -groups $curve $NXCONNECT </dev/null 2>&1 | grep -Eiaq "Error with command|unknown option|Failed to set groups"
20693+ [[ $? -ne 0 ]] && OSSL_SUPPORTED_CURVES+=" $curve "
20694+ done
20695+ fi
2067220696 else
20673- # LibreSSL (tested with version 3.4.1 and 3.0.2) need -groups instead of -curve
20674- # WSL users connect to "127.0.0.1:0", others to "invalid." or "invalid.:0"
20675- # The $OPENSSL connect call deliberately fails: when the curve isn't available with the described error messages
20697+ HAS_CURVES=true
2067620698 for curve in "${curves_ossl[@]}"; do
20677- $OPENSSL s_client -groups $curve $NXCONNECT </dev/null 2>&1 | grep -Eiaq "Error with command|unknown option|Failed to set groups"
20699+ # Same as above, we just don't need a port for invalid.
20700+ $OPENSSL s_client -curves $curve $NXCONNECT </dev/null 2>&1 | grep -Eiaq "Error with command|unknown option|Call to SSL_CONF_cmd(.*) failed|cannot be set"
2067820701 [[ $? -ne 0 ]] && OSSL_SUPPORTED_CURVES+=" $curve "
2067920702 done
2068020703 fi
20681- else
20682- HAS_CURVES=true
20683- for curve in "${curves_ossl[@]}"; do
20684- # Same as above, we just don't need a port for invalid.
20685- $OPENSSL s_client -curves $curve $NXCONNECT </dev/null 2>&1 | grep -Eiaq "Error with command|unknown option|Call to SSL_CONF_cmd(.*) failed|cannot be set"
20686- [[ $? -ne 0 ]] && OSSL_SUPPORTED_CURVES+=" $curve "
20687- done
2068820704 fi
2068920705
2069020706 # For the following we feel safe enough to query the s_client help functions.
0 commit comments