Skip to content

Commit b222c02

Browse files
authored
Fix linking ext/curl against OpenSSL (#13262)
Following 68f6ab7, 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.
1 parent aa1eaac commit b222c02

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ext/curl/config.m4

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ if test "$PHP_CURL" != "no"; then
2828

2929
AC_MSG_CHECKING([for libcurl linked against old openssl])
3030
AC_RUN_IFELSE([AC_LANG_SOURCE([[
31+
#include <stdio.h>
3132
#include <strings.h>
3233
#include <curl/curl.h>
3334
@@ -39,9 +40,18 @@ int main(int argc, char *argv[])
3940
const char *ptr = data->ssl_version;
4041
4142
while(*ptr == ' ') ++ptr;
42-
if (strncasecmp(ptr, "OpenSSL/1.1", sizeof("OpenSSL/1.1")-1) == 0) {
43-
/* New OpenSSL version */
44-
return 3;
43+
int major, minor;
44+
if (sscanf(ptr, "OpenSSL/%d", &major) == 1) {
45+
if (major >= 3) {
46+
/* OpenSSL version 3 or later */
47+
return 4;
48+
}
49+
}
50+
if (sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2) {
51+
if (major > 1 || (major == 1 && minor >= 1)) {
52+
/* OpenSSL version 1.1 or later */
53+
return 3;
54+
}
4555
}
4656
if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) {
4757
/* Old OpenSSL version */
@@ -56,11 +66,7 @@ int main(int argc, char *argv[])
5666
]])],[
5767
AC_MSG_RESULT([yes])
5868
AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1], [Have cURL with old OpenSSL])
59-
PKG_CHECK_MODULES([OPENSSL], [openssl], [
60-
PHP_EVAL_LIBLINE($OPENSSL_LIBS, CURL_SHARED_LIBADD)
61-
PHP_EVAL_INCLINE($OPENSSL_CFLAGS)
62-
AC_CHECK_HEADERS([openssl/crypto.h])
63-
], [])
69+
PHP_SETUP_OPENSSL(CURL_SHARED_LIBADD,[AC_CHECK_HEADERS([openssl/crypto.h])],[])
6470
], [
6571
AC_MSG_RESULT([no])
6672
], [

0 commit comments

Comments
 (0)