103103    OR  (CMAKE_CROSSCOMPILING  AND  CMAKE_CROSSCOMPILING_EMULATOR)
104104  )
105105)
106-   message (CHECK_START "Checking if libcurl is linked against old OpenSSL < 1.1" )
106+   message (
107+     CHECK_START
108+     "Checking whether libcurl is linked against a supported OpenSSL version" 
109+   )
107110
108111  cmake_push_check_state(RESET)
109112    set (CMAKE_REQUIRED_LIBRARIES CURL::libcurl)
@@ -127,21 +130,21 @@ if(
127130
128131          int major, minor;
129132
130-           /* OpenSSL >= 3 */
131-           if (sscanf(ptr, "OpenSSL/%d", &major) == 1 && major >= 3) {
132-             return 4;
133-           }
133+           if (sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2) {
134+             /* Check for 1.1.1+ (including 1.1.1a, 1.1.1b, etc.) */
135+             if (
136+               (major > 1)
137+               || (major == 1 && minor == 1 && strncmp(ptr + 12, "1", 1) == 0)) {
138+               /* OpenSSL 1.1.1+ - supported */
139+               return 3;
140+             }
134141
135-           /* OpenSSL >= 1.1 */
136-           if (
137-             sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2
138-             && (major > 1 || (major == 1 && minor >= 1))
139-           ) {
140-             return 3;
142+             /* OpenSSL 1.1.0 and earlier - unsupported */
143+             return 0;
141144          }
142145
143-           /* OpenSSL < 1.1 */
144146          if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) {
147+             /* Old OpenSSL version */
145148            return 0;
146149          }
147150
@@ -155,27 +158,15 @@ if(
155158    ]] PHP_EXT_CURL_HAS_CURL_OLD_OPENSSL)
156159  cmake_pop_check_state()
157160
158-   if (NOT  PHP_EXT_CURL_HAS_CURL_OLD_OPENSSL)
159-     message (CHECK_FAIL "no" )
161+   if (PHP_EXT_CURL_HAS_CURL_OLD_OPENSSL)
162+     message (CHECK_PASS "no" )
163+     message (
164+       FATAL_ERROR
165+       "libcurl is linked against an unsupported OpenSSL version. OpenSSL 1.1.1 " 
166+       "or later is required." 
167+     )
160168  else ()
161-     set (HAVE_CURL_OLD_OPENSSL TRUE )
162169    message (CHECK_PASS "yes" )
163-     find_package (OpenSSL ${PHP_OPENSSL_MIN_VERSION} )
164-     set_package_properties(
165-       OpenSSL
166-       PROPERTIES
167-         TYPE  REQUIRED
168-         PURPOSE "Necessary for crypto locking callbacks in the curl extension." 
169-     )
170- 
171-     target_link_libraries (php_ext_curl PRIVATE  OpenSSL::Crypto)
172- 
173-     if (TARGET  OpenSSL::Crypto)
174-       cmake_push_check_state(RESET)
175-         set (CMAKE_REQUIRED_LIBRARIES OpenSSL::Crypto)
176-         check_include_files(openssl/crypto.h HAVE_OPENSSL_CRYPTO_H)
177-       cmake_pop_check_state()
178-     endif ()
179170  endif ()
180171endif ()
181172
0 commit comments