Fix linking ext/curl against OpenSSL (#13262)

This is backport for 8.3 of b222c020bf
that originally targeted only 8.4+. This is however a bug fix.

Following 68f6ab7113, the ext/curl doesn't
need to be linked against OpenSSL anymore, if curl_version_info_data
ssl_version is OpenSSL/1.1 or later.

With OpenSSL 3 and later the check for old SSL crypto locking callbacks
was detected here.

This also uses a common PHP_SETUP_OPENSSL macro for checking OpenSSL and
syncs the minimum OpenSSL version (currently 1.0.2 or later) across the
PHP build system.
This commit is contained in:
Peter Kokot 2024-02-14 13:52:01 +01:00 committed by Jakub Zelenka
parent 4162c20787
commit ae92b85572
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4
2 changed files with 15 additions and 8 deletions

1
NEWS
View file

@ -8,6 +8,7 @@ PHP NEWS
- Curl: - Curl:
. Fix memory leak when setting a list via curl_setopt fails. (nielsdos) . Fix memory leak when setting a list via curl_setopt fails. (nielsdos)
. Fix incorrect OpenSSL version detection. (Peter Kokot)
- Date: - Date:
. Fix leaks with multiple calls to DatePeriod iterator current(). (nielsdos) . Fix leaks with multiple calls to DatePeriod iterator current(). (nielsdos)

View file

@ -28,6 +28,7 @@ if test "$PHP_CURL" != "no"; then
AC_MSG_CHECKING([for libcurl linked against old openssl]) AC_MSG_CHECKING([for libcurl linked against old openssl])
AC_RUN_IFELSE([AC_LANG_SOURCE([[ AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <strings.h> #include <strings.h>
#include <curl/curl.h> #include <curl/curl.h>
@ -39,9 +40,18 @@ int main(int argc, char *argv[])
const char *ptr = data->ssl_version; const char *ptr = data->ssl_version;
while(*ptr == ' ') ++ptr; while(*ptr == ' ') ++ptr;
if (strncasecmp(ptr, "OpenSSL/1.1", sizeof("OpenSSL/1.1")-1) == 0) { int major, minor;
/* New OpenSSL version */ if (sscanf(ptr, "OpenSSL/%d", &major) == 1) {
return 3; if (major >= 3) {
/* OpenSSL version 3 or later */
return 4;
}
}
if (sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2) {
if (major > 1 || (major == 1 && minor >= 1)) {
/* OpenSSL version 1.1 or later */
return 3;
}
} }
if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) { if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) {
/* Old OpenSSL version */ /* Old OpenSSL version */
@ -56,11 +66,7 @@ int main(int argc, char *argv[])
]])],[ ]])],[
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1], [Have cURL with old OpenSSL]) AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1], [Have cURL with old OpenSSL])
PKG_CHECK_MODULES([OPENSSL], [openssl], [ PHP_SETUP_OPENSSL(CURL_SHARED_LIBADD,[AC_CHECK_HEADERS([openssl/crypto.h])],[])
PHP_EVAL_LIBLINE($OPENSSL_LIBS, CURL_SHARED_LIBADD)
PHP_EVAL_INCLINE($OPENSSL_CFLAGS)
AC_CHECK_HEADERS([openssl/crypto.h])
], [])
], [ ], [
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
], [ ], [