mirror of
				https://github.com/drwetter/testssl.sh.git
				synced 2025-10-31 13:55:25 +01:00 
			
		
		
		
	OpenSSL 4 compatibility
According to https://openssl-library.org/roadmap/index.html, OpenSSL 4 is scheduled to be released in April 2026. This commit modifies code that checks $OPENSSL version numbers so that versions 4 and above will be recognized.
This commit is contained in:
		
							
								
								
									
										34
									
								
								testssl.sh
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								testssl.sh
									
									
									
									
									
								
							| @@ -2083,7 +2083,7 @@ check_revocation_ocsp() { | |||||||
|           if [[ "$OSSL_NAME" =~ LibreSSL ]]; then |           if [[ "$OSSL_NAME" =~ LibreSSL ]]; then | ||||||
|                host_header="-header Host ${host_header}" |                host_header="-header Host ${host_header}" | ||||||
|           elif [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.0* ]] || [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.1* ]] || \ |           elif [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.0* ]] || [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.1* ]] || \ | ||||||
|                [[ $OSSL_VER_MAJOR == 3 ]]; then |                [[ $OSSL_VER_MAJOR -ge 3 ]]; then | ||||||
|                host_header="-header Host=${host_header}" |                host_header="-header Host=${host_header}" | ||||||
|           else |           else | ||||||
|                host_header="-header Host ${host_header}" |                host_header="-header Host ${host_header}" | ||||||
| @@ -4443,7 +4443,7 @@ ciphers_by_strength() { | |||||||
|                ossl_ciphers_proto="" |                ossl_ciphers_proto="" | ||||||
|           elif [[ $proto == -ssl2 ]] || [[ $proto == -ssl3 ]] || \ |           elif [[ $proto == -ssl2 ]] || [[ $proto == -ssl3 ]] || \ | ||||||
|                [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.0* ]] || [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.1* ]] || \ |                [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.0* ]] || [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.1* ]] || \ | ||||||
|                [[ $OSSL_VER_MAJOR == 3 ]]; then |                [[ $OSSL_VER_MAJOR -ge 3 ]]; then | ||||||
|                ossl_ciphers_proto="$proto" |                ossl_ciphers_proto="$proto" | ||||||
|           else |           else | ||||||
|                ossl_ciphers_proto="-tls1" |                ossl_ciphers_proto="-tls1" | ||||||
| @@ -6852,7 +6852,7 @@ sub_session_resumption() { | |||||||
|           fi |           fi | ||||||
|      fi |      fi | ||||||
|      if "$byID" && [[ ! "$OSSL_NAME" =~ LibreSSL ]] && \ |      if "$byID" && [[ ! "$OSSL_NAME" =~ LibreSSL ]] && \ | ||||||
|         [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.1* || $OSSL_VER_MAJOR == 3 ]] && \ |         [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.1* || $OSSL_VER_MAJOR -ge 3 ]] && \ | ||||||
|         [[ ! -s "$sess_data" ]]; then |         [[ ! -s "$sess_data" ]]; then | ||||||
|           # it seems OpenSSL indicates no Session ID resumption by just not generating output |           # it seems OpenSSL indicates no Session ID resumption by just not generating output | ||||||
|           debugme echo -n "No session resumption byID (empty file)" |           debugme echo -n "No session resumption byID (empty file)" | ||||||
| @@ -7706,15 +7706,13 @@ determine_trust() { | |||||||
|      # and the output should should be indented by two more spaces. |      # and the output should should be indented by two more spaces. | ||||||
|      [[ -n $json_postfix ]] && spaces="                                " |      [[ -n $json_postfix ]] && spaces="                                " | ||||||
| 
 | 
 | ||||||
|      case $OSSL_VER_MAJOR.$OSSL_VER_MINOR in |      if [[ $OSSL_VER_MAJOR -lt 3 ]] && [[ "$OSSL_VER_MAJOR.$OSSL_VER_MINOR" != 1.0.2 ]] && \ | ||||||
|           1.0.2|1.1.0|1.1.1|2.[1-9].*|3.*|4.*)           # 2.x is LibreSSL. 2.1.1 was tested to work, below is not sure |         [[ "$OSSL_VER_MAJOR.$OSSL_VER_MINOR" != 1.1.* ]] && [[ "$OSSL_VER_MAJOR.$OSSL_VER_MINOR" != 2.[1-9].* ]]; then | ||||||
|                : |           # 2.x is LibreSSL. 2.1.1 was tested to work, below is not sure | ||||||
|           ;; |           addtl_warning="Your $OPENSSL <= 1.0.2 might be too unreliable to determine trust" | ||||||
|           *)   addtl_warning="Your $OPENSSL <= 1.0.2 might be too unreliable to determine trust" |           fileout "${jsonID}${json_postfix}" "WARN" "$addtl_warning" | ||||||
|                fileout "${jsonID}${json_postfix}" "WARN" "$addtl_warning" |           addtl_warning="(${addtl_warning})" | ||||||
|                addtl_warning="(${addtl_warning})" |      fi | ||||||
|           ;; |  | ||||||
|      esac |  | ||||||
|      debugme tmln_out |      debugme tmln_out | ||||||
| 
 | 
 | ||||||
|      # if you run testssl.sh from a different path /you can set either TESTSSL_INSTALL_DIR or CA_BUNDLES_PATH to find the CA BUNDLES |      # if you run testssl.sh from a different path /you can set either TESTSSL_INSTALL_DIR or CA_BUNDLES_PATH to find the CA BUNDLES | ||||||
| @@ -12503,7 +12501,7 @@ hmac() { | |||||||
|      local key="$2" text="$3" output |      local key="$2" text="$3" output | ||||||
|      local -i ret |      local -i ret | ||||||
| 
 | 
 | ||||||
|      if [[ ! "$OSSL_NAME" =~ LibreSSL ]] && [[ $OSSL_VER_MAJOR == 3 ]]; then |      if [[ ! "$OSSL_NAME" =~ LibreSSL ]] && [[ $OSSL_VER_MAJOR -ge 3 ]]; then | ||||||
|           output="$(hex2binary "$text" | $OPENSSL mac -macopt digest:"${hash_fn/-/}" -macopt hexkey:"$key" HMAC 2>/dev/null)" |           output="$(hex2binary "$text" | $OPENSSL mac -macopt digest:"${hash_fn/-/}" -macopt hexkey:"$key" HMAC 2>/dev/null)" | ||||||
|           ret=$? |           ret=$? | ||||||
|           tm_out "$(strip_lf "$output")" |           tm_out "$(strip_lf "$output")" | ||||||
| @@ -12524,7 +12522,7 @@ hmac-transcript() { | |||||||
|      local key="$2" transcript="$3" output |      local key="$2" transcript="$3" output | ||||||
|      local -i ret |      local -i ret | ||||||
| 
 | 
 | ||||||
|      if [[ ! "$OSSL_NAME" =~ LibreSSL ]] && [[ $OSSL_VER_MAJOR == 3 ]]; then |      if [[ ! "$OSSL_NAME" =~ LibreSSL ]] && [[ $OSSL_VER_MAJOR -ge 3 ]]; then | ||||||
|           output="$(hex2binary "$transcript" | \ |           output="$(hex2binary "$transcript" | \ | ||||||
|                     $OPENSSL dgst "$hash_fn" -binary 2>/dev/null | \ |                     $OPENSSL dgst "$hash_fn" -binary 2>/dev/null | \ | ||||||
|                     $OPENSSL mac -macopt digest:"${hash_fn/-/}" -macopt hexkey:"$key" HMAC 2>/dev/null)" |                     $OPENSSL mac -macopt digest:"${hash_fn/-/}" -macopt hexkey:"$key" HMAC 2>/dev/null)" | ||||||
| @@ -20477,9 +20475,9 @@ find_openssl_binary() { | |||||||
|      OSSL_NAME=${OSSL_NAME//  /} |      OSSL_NAME=${OSSL_NAME//  /} | ||||||
| 
 | 
 | ||||||
|      # see #190, reverting logic: unless otherwise proved openssl has no dh bits |      # see #190, reverting logic: unless otherwise proved openssl has no dh bits | ||||||
|      case "$OSSL_VER_MAJOR.$OSSL_VER_MINOR" in |      if [[ $OSSL_VER_MAJOR -ge 3 ]] || [[ "$OSSL_VER_MAJOR.$OSSL_VER_MINOR" == 1.1.* ]] || [[ "$OSSL_VER_MAJOR.$OSSL_VER_MINOR" == 1.0.2 ]]; then | ||||||
|           1.0.2|1.1.0|1.1.1|3.*) HAS_DH_BITS=true ;; |           HAS_DH_BITS=true | ||||||
|      esac |      fi | ||||||
| 
 | 
 | ||||||
|      OPENSSL_NR_CIPHERS=$(count_ciphers "$(actually_supported_osslciphers 'ALL:COMPLEMENTOFALL' 'ALL')") |      OPENSSL_NR_CIPHERS=$(count_ciphers "$(actually_supported_osslciphers 'ALL:COMPLEMENTOFALL' 'ALL')") | ||||||
| 
 | 
 | ||||||
| @@ -20625,7 +20623,7 @@ find_openssl_binary() { | |||||||
|      # not check /usr/bin/openssl -- if available. This is more a kludge which we shouldn't use for |      # not check /usr/bin/openssl -- if available. This is more a kludge which we shouldn't use for | ||||||
|      # every openssl feature. At some point we need to decide which with openssl version we go. |      # every openssl feature. At some point we need to decide which with openssl version we go. | ||||||
|      # We also check, whether there's /usr/bin/openssl which has TLS 1.3 |      # We also check, whether there's /usr/bin/openssl which has TLS 1.3 | ||||||
|      if [[ ! "$OSSL_NAME" =~ LibreSSL ]] && [[ ! $OSSL_VER =~ 1.1.1 ]] && [[ ! $OSSL_VER_MAJOR =~ 3 ]]; then |      if [[ ! "$OSSL_NAME" =~ LibreSSL ]] && [[ ! $OSSL_VER =~ 1.1.1 ]] && [[ $OSSL_VER_MAJOR -lt 3 ]]; then | ||||||
|           if [[ -x $OPENSSL2 ]]; then |           if [[ -x $OPENSSL2 ]]; then | ||||||
|                $OPENSSL2 s_client -help 2>$s_client_has2 |                $OPENSSL2 s_client -help 2>$s_client_has2 | ||||||
|                $OPENSSL2 s_client -starttls foo 2>$s_client_starttls_has2 |                $OPENSSL2 s_client -starttls foo 2>$s_client_starttls_has2 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 David Cooper
					David Cooper