@@ -27,7 +27,6 @@ project(
2727  LANGUAGES C
2828)
2929
30- include (CheckIncludeFiles)
3130include (CheckSourceRuns)
3231include (CMakeDependentOption)
3332include (CMakePushCheckState)
103102    OR  (CMAKE_CROSSCOMPILING  AND  CMAKE_CROSSCOMPILING_EMULATOR)
104103  )
105104)
106-   message (CHECK_START "Checking if libcurl is linked against old OpenSSL < 1.1" )
105+   message (
106+     CHECK_START
107+     "Checking whether libcurl is linked against a supported OpenSSL version" 
108+   )
107109
108110  cmake_push_check_state(RESET)
109111    set (CMAKE_REQUIRED_LIBRARIES CURL::libcurl)
@@ -127,21 +129,21 @@ if(
127129
128130          int major, minor;
129131
130-           /* OpenSSL >= 3 */
131-           if (sscanf(ptr, "OpenSSL/%d", &major) == 1 && major >= 3) {
132-             return 4;
133-           }
132+           if (sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2) {
133+             /* Check for 1.1.1+ (including 1.1.1a, 1.1.1b, etc.) */
134+             if (
135+               (major > 1)
136+               || (major == 1 && minor == 1 && strncmp(ptr + 12, "1", 1) == 0)) {
137+               /* OpenSSL 1.1.1+ - supported */
138+               return 3;
139+             }
134140
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;
141+             /* OpenSSL 1.1.0 and earlier - unsupported */
142+             return 0;
141143          }
142144
143-           /* OpenSSL < 1.1 */
144145          if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) {
146+             /* Old OpenSSL version */
145147            return 0;
146148          }
147149
@@ -155,27 +157,15 @@ if(
155157    ]] PHP_EXT_CURL_HAS_CURL_OLD_OPENSSL)
156158  cmake_pop_check_state()
157159
158-   if (NOT   PHP_EXT_CURL_HAS_CURL_OLD_OPENSSL)
160+   if (PHP_EXT_CURL_HAS_CURL_OLD_OPENSSL)
159161    message (CHECK_FAIL "no" )
162+     message (
163+       FATAL_ERROR
164+       "libcurl is linked against an unsupported OpenSSL version. OpenSSL " 
165+       "${PHP_OPENSSL_MIN_VERSION}  or later is required." 
166+     )
160167  else ()
161-     set (HAVE_CURL_OLD_OPENSSL TRUE )
162168    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 ()
179169  endif ()
180170endif ()
181171
0 commit comments