From d758be5353448f9a72764198a6bf9d86b09daa2a Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 24 May 2023 18:26:55 +0200 Subject: [PATCH] curl: CURLOPT_TLSAUTH_TYPE never accepted enum CURL_TLSAUTH :facepalm: --- autoconf/pecl/libcurl.m4 | 30 +++++---------------- scripts/gen_github_workflow_curl-matrix.php | 2 +- src/php_http_client_curl.c | 6 +++-- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/autoconf/pecl/libcurl.m4 b/autoconf/pecl/libcurl.m4 index 8de9499..f630b06 100644 --- a/autoconf/pecl/libcurl.m4 +++ b/autoconf/pecl/libcurl.m4 @@ -126,38 +126,22 @@ AC_DEFUN([PECL_HAVE_LIBCURL_SSL], [dnl ;; esac - PECL_HAVE_CONST([curl/curl.h], [CURLOPT_TLSAUTH_TYPE], int, [ - AC_CACHE_CHECK([whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP], PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP]), [ - PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])= + PECL_HAVE_CONST([curl/curl.h], [CURL_VERSION_TLSAUTH_SRP], int, [ + AC_CACHE_CHECK([for CURLOPT_TLSAUTH_TYPE SRP support], PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP]), [ + PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=no AC_TRY_RUN([ #include int main(int argc, char *argv[]) { - CURL *ch = curl_easy_init(); - return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, CURL_TLSAUTH_SRP); + int has_feature = curl_version_info(CURLVERSION_NOW)->features & CURL_VERSION_TLSAUTH_SRP; + int set_failure = curl_easy_setopt(curl_easy_init(), CURLOPT_TLSAUTH_TYPE, "SRP""); + return !has_feature || set_failure; } ], [ PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=yes - ], [ - AC_TRY_RUN([ - #include - int main(int argc, char *argv[]) { - CURL *ch = curl_easy_init(); - return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, "SRP"); - } - ], [ - PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=no - ]) ]) ]) - if test -n "$PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])"; then + if test "$PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])" = "yes"; then PECL_DEFINE([HAVE_LIBCURL_TLSAUTH_TYPE]) - if $PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP]); then - PECL_DEFINE([LIBCURL_TLSAUTH_SRP], [CURL_TLSAUTH_SRP]) - PECL_DEFINE([LIBCURL_TLSAUTH_DEF], [CURL_TLSAUTH_NONE]) - else - PECL_DEFINE([LIBCURL_TLSAUTH_SRP], ["SRP"]) - PECL_DEFINE([LIBCURL_TLSAUTH_DEF], [""]) - fi fi ]) diff --git a/scripts/gen_github_workflow_curl-matrix.php b/scripts/gen_github_workflow_curl-matrix.php index be6748b..beaa65d 100755 --- a/scripts/gen_github_workflow_curl-matrix.php +++ b/scripts/gen_github_workflow_curl-matrix.php @@ -83,7 +83,7 @@ foreach ($job as $id => $env) { sudo ln -s /usr/share/libtool/build-aux/ltmain.sh /usr/bin/libtool cd curl ./buildconf - ./configure --prefix=/opt --disable-dependency-tracking --with-ssl --with-openssl --without-libssh2 + ./configure --prefix=/opt --disable-dependency-tracking --with-ssl --with-openssl --without-libssh2 --disable-ldap make -j2 make install - name: Prepare diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c index 46502ba..156c569 100644 --- a/src/php_http_client_curl.c +++ b/src/php_http_client_curl.c @@ -1202,8 +1202,10 @@ static ZEND_RESULT_CODE php_http_curle_option_set_ssl_tlsauthtype(php_http_optio if (val && Z_LVAL_P(val)) { switch (Z_LVAL_P(val)) { + case CURL_TLSAUTH_NONE: + break; case CURL_TLSAUTH_SRP: - if (CURLE_OK == curl_easy_setopt(ch, opt->option, PHP_HTTP_LIBCURL_TLSAUTH_SRP)) { + if (CURLE_OK == curl_easy_setopt(ch, opt->option, "SRP")) { return SUCCESS; } /* no break */ @@ -1211,7 +1213,7 @@ static ZEND_RESULT_CODE php_http_curle_option_set_ssl_tlsauthtype(php_http_optio return FAILURE; } } - if (CURLE_OK != curl_easy_setopt(ch, opt->option, PHP_HTTP_LIBCURL_TLSAUTH_DEF)) { + if (CURLE_OK != curl_easy_setopt(ch, opt->option, "NONE")) { return FAILURE; } return SUCCESS; -- 2.30.2