From 4f9a720595a599a8b00d77b1e2ea1c917c8ea77d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 1 Nov 2026 16:19:20 +0800 Subject: [PATCH 1/4] fix(curl): enhance Windows TLS backend support and update documentation --- config/env.ini | 2 ++ docs/en/guide/extension-notes.md | 8 ++++++++ docs/zh/guide/extension-notes.md | 7 +++++++ src/Package/Extension/curl.php | 7 ++++--- src/Package/Target/curl.php | 26 +++++++++++++++++++++++--- 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/config/env.ini b/config/env.ini index ea78e7666..4967d90d1 100644 --- a/config/env.ini +++ b/config/env.ini @@ -82,6 +82,8 @@ SPC_MSYS2_PATH="${PKG_ROOT_PATH}\msys2-build-essentials\msys64" UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe" ; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static,win32_api +; TLS backend used when building libcurl: "schannel" (default) or "openssl" +SPC_CURL_TLS_BACKEND=schannel [linux] ; Linux can use different build toolchains. diff --git a/docs/en/guide/extension-notes.md b/docs/en/guide/extension-notes.md index 7804b1dfd..78505be27 100644 --- a/docs/en/guide/extension-notes.md +++ b/docs/en/guide/extension-notes.md @@ -11,6 +11,14 @@ HTTP3 support is not enabled by default, compile with `--with-libs="nghttp2,nght When using curl to request HTTPS, there may be an `error:80000002:system library::No such file or directory` error. For details on the solution, see [FAQ](../faq/). +On Windows, libcurl is built with the Schannel TLS backend by default, and it verifies certificates +against the Windows certificate store. Schannel ignores `CURLOPT_SSLKEY`, so PEM client certificates +(mutual TLS) cannot be used with the default build. +Build with `SPC_CURL_TLS_BACKEND=openssl` to switch libcurl to OpenSSL instead; certificate verification +then still reads the Windows certificate store (`CURL_CA_NATIVE`), so the binary does not need a bundled +CA file. This backend requires curl >= 8.19; see [Environment Variables](./env-vars) for how to set it. +Changing the backend requires rebuilding libcurl: remove `buildroot/lib/libcurl_a.lib` or run `spc reset`. + ## phpmicro 1. Only PHP >= 8.0 is supported. diff --git a/docs/zh/guide/extension-notes.md b/docs/zh/guide/extension-notes.md index f43fea7ee..4d7b3636a 100644 --- a/docs/zh/guide/extension-notes.md +++ b/docs/zh/guide/extension-notes.md @@ -9,6 +9,13 @@ HTTP3 支持默认未启用,需在编译时添加 `--with-libs="nghttp2,nghttp 使用 curl 请求 HTTPS 时,可能存在 `error:80000002:system library::No such file or directory` 错误, 解决办法详见 [FAQ](../faq/)。 +Windows 上 libcurl 默认使用 Schannel 作为 TLS 后端,证书校验读取 Windows 证书存储。 +Schannel 会忽略 `CURLOPT_SSLKEY`,因此默认构建无法使用 PEM 格式的客户端证书(双向 TLS)。 +如需使用,可通过 `SPC_CURL_TLS_BACKEND=openssl` 让 libcurl 改用 OpenSSL; +此时证书校验仍然读取 Windows 证书存储(`CURL_CA_NATIVE`),二进制无需内置 CA 证书文件。 +该后端要求 curl >= 8.19,设置方式见[环境变量](./env-vars)。 +切换后端后需要重新构建 libcurl:删除 `buildroot/lib/libcurl_a.lib` 或执行 `spc reset`。 + ## phpmicro 1. phpmicro SAPI 仅支持 PHP >= 8.0 版本。 diff --git a/src/Package/Extension/curl.php b/src/Package/Extension/curl.php index fc1944913..f341e67a2 100644 --- a/src/Package/Extension/curl.php +++ b/src/Package/Extension/curl.php @@ -13,11 +13,12 @@ class curl { #[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-curl')] - #[PatchDescription('Inject secur32.lib into SPC_EXTRA_LIBS for Schannel SSL support')] + #[PatchDescription('Inject secur32.lib into SPC_EXTRA_LIBS for Windows SSPI support')] public function addSecur32LibForWindows(): void { - // curl on Windows uses Schannel (USE_WINDOWS_SSPI=ON, CURL_USE_SCHANNEL=ON), - // which requires secur32.lib for SSL/TLS functions (SslEncryptPackage, etc.). + // libcurl on Windows is always built with CURL_WINDOWS_SSPI=ON (NTLM/SPNEGO/SMB), + // which requires secur32.lib for the SSPI functions. This is independent of the + // selected TLS backend (Schannel by default, OpenSSL via SPC_CURL_TLS_BACKEND). $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; if (!str_contains($extra_libs, 'secur32.lib')) { putenv('SPC_EXTRA_LIBS=' . trim("{$extra_libs} secur32.lib")); diff --git a/src/Package/Target/curl.php b/src/Package/Target/curl.php index 66c62490d..e35338971 100644 --- a/src/Package/Target/curl.php +++ b/src/Package/Target/curl.php @@ -38,6 +38,28 @@ public function buildWin(LibraryPackage $lib): void $lib_dir = str_replace('\\', '/', $lib->getLibDir()); $zstd_lib = "{$lib_dir}/zstd_static.lib"; $extra_libs = "{$lib_dir}/libcrypto.lib {$lib_dir}/libssl.lib ws2_32.lib gdi32.lib advapi32.lib crypt32.lib user32.lib"; + $schannel_backend_args = [ + '-DCURL_WINDOWS_SSPI=ON', + '-DCURL_USE_SCHANNEL=ON', + '-DCURL_USE_OPENSSL=OFF', + ]; + $ossl_backend_args = [ + // Keep Windows SSPI (NTLM/SPNEGO/SMB) for both TLS backends + '-DCURL_WINDOWS_SSPI=ON', + '-DCURL_USE_SCHANNEL=OFF', + '-DCURL_USE_OPENSSL=ON', + '-DCURL_CA_NATIVE=ON', + '-DCURL_CA_BUNDLE=none', + '-DCURL_CA_PATH=none', + '-DOPENSSL_ROOT_DIR=' . escapeshellarg(str_replace('\\', '/', BUILD_ROOT_PATH)), + '-DOPENSSL_USE_STATIC_LIBS=ON', + ]; + $backend = getenv('SPC_CURL_TLS_BACKEND') ?: 'schannel'; + $backend_args = $backend === 'openssl' ? $ossl_backend_args : $schannel_backend_args; + logger()->info("Building libcurl with TLS backend [{$backend}] (SPC_CURL_TLS_BACKEND)"); + if (!in_array($backend, ['openssl', 'schannel'])) { + logger()->warning("SPC_CURL_TLS_BACKEND can only pass 'schannel' and 'openssl', now fallback to 'schannel'"); + } WindowsCMakeExecutor::create($lib) ->optionalPackage('zstd', ...cmake_boolean_args('CURL_ZSTD')) ->optionalPackage('brotli', ...cmake_boolean_args('CURL_BROTLI')) @@ -51,14 +73,12 @@ public function buildWin(LibraryPackage $lib): void '-DENABLE_CURL_MANUAL=OFF', '-DUSE_LIBIDN2=OFF', '-DCURL_USE_LIBPSL=OFF', - '-DUSE_WINDOWS_SSPI=ON', - '-DCURL_USE_SCHANNEL=ON', - '-DCURL_USE_OPENSSL=OFF', '-DCURL_ENABLE_SSL=ON', '-DUSE_NGHTTP2=ON', '-DSHARE_LIB_OBJECT=OFF', '-DCURL_USE_LIBSSH2=ON', '-DENABLE_IPV6=ON', + ...$backend_args, ) ->build(); // move libcurl.lib to libcurl_a.lib From 92ce5cb982f2431f9768208b989bbb9ce52c0d7b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 1 Nov 2026 23:23:03 +0800 Subject: [PATCH 2/4] fix(curl): update default TLS backend to OpenSSL and enhance documentation --- config/env.ini | 9 +++++++-- config/pkg/target/curl.yml | 1 + docs/en/guide/extension-notes.md | 13 +++++++------ docs/zh/guide/extension-notes.md | 9 ++++----- src/Package/Extension/curl.php | 2 +- src/Package/Target/curl.php | 6 +++--- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/config/env.ini b/config/env.ini index 4967d90d1..3e38604d2 100644 --- a/config/env.ini +++ b/config/env.ini @@ -82,8 +82,13 @@ SPC_MSYS2_PATH="${PKG_ROOT_PATH}\msys2-build-essentials\msys64" UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe" ; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static,win32_api -; TLS backend used when building libcurl: "schannel" (default) or "openssl" -SPC_CURL_TLS_BACKEND=schannel +; TLS backend used when building libcurl: "openssl" (default) or "schannel" +; openssl matches the official PHP Windows builds and the Unix builds: it supports PEM client +; certificates (mutual TLS) and verifies against the Windows certificate store (CURL_CA_NATIVE), +; so no CA bundle file is required. +; Use "schannel" to follow the Windows TLS policy (cipher suites, revocation checks) or to +; reference client certificates from the Windows certificate store. +SPC_CURL_TLS_BACKEND=openssl [linux] ; Linux can use different build toolchains. diff --git a/config/pkg/target/curl.yml b/config/pkg/target/curl.yml index 8140bf728..b65bbd650 100644 --- a/config/pkg/target/curl.yml +++ b/config/pkg/target/curl.yml @@ -14,6 +14,7 @@ curl: - zlib depends@windows: - zlib + - openssl - libssh2 - nghttp2 - brotli diff --git a/docs/en/guide/extension-notes.md b/docs/en/guide/extension-notes.md index 78505be27..c9e9d96ae 100644 --- a/docs/en/guide/extension-notes.md +++ b/docs/en/guide/extension-notes.md @@ -11,12 +11,13 @@ HTTP3 support is not enabled by default, compile with `--with-libs="nghttp2,nght When using curl to request HTTPS, there may be an `error:80000002:system library::No such file or directory` error. For details on the solution, see [FAQ](../faq/). -On Windows, libcurl is built with the Schannel TLS backend by default, and it verifies certificates -against the Windows certificate store. Schannel ignores `CURLOPT_SSLKEY`, so PEM client certificates -(mutual TLS) cannot be used with the default build. -Build with `SPC_CURL_TLS_BACKEND=openssl` to switch libcurl to OpenSSL instead; certificate verification -then still reads the Windows certificate store (`CURL_CA_NATIVE`), so the binary does not need a bundled -CA file. This backend requires curl >= 8.19; see [Environment Variables](./env-vars) for how to set it. +On Windows, libcurl is built with the OpenSSL TLS backend by default, matching the official PHP +Windows builds and the Unix builds. Certificate verification reads the Windows certificate store +(`CURL_CA_NATIVE`), so the binary does not need a bundled CA file, and PEM client certificates +(mutual TLS) work out of the box. +Set `SPC_CURL_TLS_BACKEND=schannel` to use the Windows native TLS stack instead: it follows the +Windows TLS policy (cipher suites, revocation checks) and can load client certificates from the +Windows certificate store, but it ignores `CURLOPT_SSLKEY`, so PEM client certificates cannot be used. Changing the backend requires rebuilding libcurl: remove `buildroot/lib/libcurl_a.lib` or run `spc reset`. ## phpmicro diff --git a/docs/zh/guide/extension-notes.md b/docs/zh/guide/extension-notes.md index 4d7b3636a..fd7d5f998 100644 --- a/docs/zh/guide/extension-notes.md +++ b/docs/zh/guide/extension-notes.md @@ -9,11 +9,10 @@ HTTP3 支持默认未启用,需在编译时添加 `--with-libs="nghttp2,nghttp 使用 curl 请求 HTTPS 时,可能存在 `error:80000002:system library::No such file or directory` 错误, 解决办法详见 [FAQ](../faq/)。 -Windows 上 libcurl 默认使用 Schannel 作为 TLS 后端,证书校验读取 Windows 证书存储。 -Schannel 会忽略 `CURLOPT_SSLKEY`,因此默认构建无法使用 PEM 格式的客户端证书(双向 TLS)。 -如需使用,可通过 `SPC_CURL_TLS_BACKEND=openssl` 让 libcurl 改用 OpenSSL; -此时证书校验仍然读取 Windows 证书存储(`CURL_CA_NATIVE`),二进制无需内置 CA 证书文件。 -该后端要求 curl >= 8.19,设置方式见[环境变量](./env-vars)。 +Windows 上 libcurl 默认使用 OpenSSL 作为 TLS 后端,与官方 PHP Windows 构建及 Unix 构建保持一致。 +证书校验读取 Windows 证书存储(`CURL_CA_NATIVE`),二进制无需内置 CA 证书文件,PEM 格式的客户端证书(双向 TLS)可直接使用。 +如需使用 Windows 原生 TLS,可设置 `SPC_CURL_TLS_BACKEND=schannel`:它会遵循 Windows 的 TLS 策略(密码套件、吊销检查), +并可从 Windows 证书存储读取客户端证书;但它会忽略 `CURLOPT_SSLKEY`,因此无法使用 PEM 格式的客户端证书。 切换后端后需要重新构建 libcurl:删除 `buildroot/lib/libcurl_a.lib` 或执行 `spc reset`。 ## phpmicro diff --git a/src/Package/Extension/curl.php b/src/Package/Extension/curl.php index f341e67a2..53c8b52e8 100644 --- a/src/Package/Extension/curl.php +++ b/src/Package/Extension/curl.php @@ -18,7 +18,7 @@ public function addSecur32LibForWindows(): void { // libcurl on Windows is always built with CURL_WINDOWS_SSPI=ON (NTLM/SPNEGO/SMB), // which requires secur32.lib for the SSPI functions. This is independent of the - // selected TLS backend (Schannel by default, OpenSSL via SPC_CURL_TLS_BACKEND). + // selected TLS backend (OpenSSL by default, Schannel via SPC_CURL_TLS_BACKEND). $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; if (!str_contains($extra_libs, 'secur32.lib')) { putenv('SPC_EXTRA_LIBS=' . trim("{$extra_libs} secur32.lib")); diff --git a/src/Package/Target/curl.php b/src/Package/Target/curl.php index e35338971..7f86766e5 100644 --- a/src/Package/Target/curl.php +++ b/src/Package/Target/curl.php @@ -54,11 +54,11 @@ public function buildWin(LibraryPackage $lib): void '-DOPENSSL_ROOT_DIR=' . escapeshellarg(str_replace('\\', '/', BUILD_ROOT_PATH)), '-DOPENSSL_USE_STATIC_LIBS=ON', ]; - $backend = getenv('SPC_CURL_TLS_BACKEND') ?: 'schannel'; - $backend_args = $backend === 'openssl' ? $ossl_backend_args : $schannel_backend_args; + $backend = getenv('SPC_CURL_TLS_BACKEND') ?: 'openssl'; + $backend_args = $backend === 'schannel' ? $schannel_backend_args : $ossl_backend_args; logger()->info("Building libcurl with TLS backend [{$backend}] (SPC_CURL_TLS_BACKEND)"); if (!in_array($backend, ['openssl', 'schannel'])) { - logger()->warning("SPC_CURL_TLS_BACKEND can only pass 'schannel' and 'openssl', now fallback to 'schannel'"); + logger()->warning("SPC_CURL_TLS_BACKEND can only pass 'schannel' and 'openssl', now fallback to 'openssl'"); } WindowsCMakeExecutor::create($lib) ->optionalPackage('zstd', ...cmake_boolean_args('CURL_ZSTD')) From 4ada82f5ec3be32d0efd6c4d976a8446b96eca77 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 2 Nov 2026 07:43:45 +0800 Subject: [PATCH 3/4] fix(clickhouse): link libcrypto/libz for the static libssl configure check The upstream config.m4 probes libssl with PHP_CHECK_LIBRARY(ssl, SSL_CTX_new) without naming the libraries libssl.a itself depends on, so the conftest fails with undefined libcrypto symbols in static builds and configure aborts with: configure: error: --enable-clickhouse-openssl requires libssl, ... Any build that resolves the openssl library (for example an extension batch that also contains curl, or --with-suggests) enables --enable-clickhouse-openssl in the package hook, so this broke the Linux and macOS ext test matrices. Preload libcrypto/libz into LIBS right before that check. Verified with a static macOS build: "checking for SSL_CTX_new in -lssl... yes", the build completes and the resulting php loads the clickhouse extension. --- src/Package/Extension/clickhouse.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Package/Extension/clickhouse.php b/src/Package/Extension/clickhouse.php index b09551ab8..b5fa2bbe9 100644 --- a/src/Package/Extension/clickhouse.php +++ b/src/Package/Extension/clickhouse.php @@ -41,5 +41,15 @@ public function patchBeforeBuildconf(): void '' ); } + + // upstream checks libssl with PHP_CHECK_LIBRARY(ssl, SSL_CTX_new) without naming the + // libraries libssl.a itself depends on, so the conftest fails with undefined libcrypto + // symbols for static builds: configure aborts with "requires libssl, which was not found". + // Preload libcrypto/libz into LIBS for that check (it is guarded by --enable-clickhouse-openssl). + FileSystem::replaceFileStr( + $this->getBuildDir() . '/config.m4', + ' PHP_CHECK_LIBRARY(ssl, SSL_CTX_new, [', + ' LIBS="$LIBS -lcrypto -lz"' . "\n" . ' PHP_CHECK_LIBRARY(ssl, SSL_CTX_new, [' + ); } } From 046da0aababf7a4cb09c0d54261c8ccd54c8d548 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 2 Nov 2026 15:07:13 +0800 Subject: [PATCH 4/4] fix(curl): streamline Windows TLS backend configuration and update documentation --- config/env.ini | 7 ------- docs/en/guide/extension-notes.md | 9 --------- docs/zh/guide/extension-notes.md | 6 ------ src/Package/Extension/curl.php | 5 ++--- src/Package/Target/curl.php | 31 ++++++++----------------------- 5 files changed, 10 insertions(+), 48 deletions(-) diff --git a/config/env.ini b/config/env.ini index 3e38604d2..ea78e7666 100644 --- a/config/env.ini +++ b/config/env.ini @@ -82,13 +82,6 @@ SPC_MSYS2_PATH="${PKG_ROOT_PATH}\msys2-build-essentials\msys64" UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe" ; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static,win32_api -; TLS backend used when building libcurl: "openssl" (default) or "schannel" -; openssl matches the official PHP Windows builds and the Unix builds: it supports PEM client -; certificates (mutual TLS) and verifies against the Windows certificate store (CURL_CA_NATIVE), -; so no CA bundle file is required. -; Use "schannel" to follow the Windows TLS policy (cipher suites, revocation checks) or to -; reference client certificates from the Windows certificate store. -SPC_CURL_TLS_BACKEND=openssl [linux] ; Linux can use different build toolchains. diff --git a/docs/en/guide/extension-notes.md b/docs/en/guide/extension-notes.md index c9e9d96ae..7804b1dfd 100644 --- a/docs/en/guide/extension-notes.md +++ b/docs/en/guide/extension-notes.md @@ -11,15 +11,6 @@ HTTP3 support is not enabled by default, compile with `--with-libs="nghttp2,nght When using curl to request HTTPS, there may be an `error:80000002:system library::No such file or directory` error. For details on the solution, see [FAQ](../faq/). -On Windows, libcurl is built with the OpenSSL TLS backend by default, matching the official PHP -Windows builds and the Unix builds. Certificate verification reads the Windows certificate store -(`CURL_CA_NATIVE`), so the binary does not need a bundled CA file, and PEM client certificates -(mutual TLS) work out of the box. -Set `SPC_CURL_TLS_BACKEND=schannel` to use the Windows native TLS stack instead: it follows the -Windows TLS policy (cipher suites, revocation checks) and can load client certificates from the -Windows certificate store, but it ignores `CURLOPT_SSLKEY`, so PEM client certificates cannot be used. -Changing the backend requires rebuilding libcurl: remove `buildroot/lib/libcurl_a.lib` or run `spc reset`. - ## phpmicro 1. Only PHP >= 8.0 is supported. diff --git a/docs/zh/guide/extension-notes.md b/docs/zh/guide/extension-notes.md index fd7d5f998..f43fea7ee 100644 --- a/docs/zh/guide/extension-notes.md +++ b/docs/zh/guide/extension-notes.md @@ -9,12 +9,6 @@ HTTP3 支持默认未启用,需在编译时添加 `--with-libs="nghttp2,nghttp 使用 curl 请求 HTTPS 时,可能存在 `error:80000002:system library::No such file or directory` 错误, 解决办法详见 [FAQ](../faq/)。 -Windows 上 libcurl 默认使用 OpenSSL 作为 TLS 后端,与官方 PHP Windows 构建及 Unix 构建保持一致。 -证书校验读取 Windows 证书存储(`CURL_CA_NATIVE`),二进制无需内置 CA 证书文件,PEM 格式的客户端证书(双向 TLS)可直接使用。 -如需使用 Windows 原生 TLS,可设置 `SPC_CURL_TLS_BACKEND=schannel`:它会遵循 Windows 的 TLS 策略(密码套件、吊销检查), -并可从 Windows 证书存储读取客户端证书;但它会忽略 `CURLOPT_SSLKEY`,因此无法使用 PEM 格式的客户端证书。 -切换后端后需要重新构建 libcurl:删除 `buildroot/lib/libcurl_a.lib` 或执行 `spc reset`。 - ## phpmicro 1. phpmicro SAPI 仅支持 PHP >= 8.0 版本。 diff --git a/src/Package/Extension/curl.php b/src/Package/Extension/curl.php index 53c8b52e8..55618463f 100644 --- a/src/Package/Extension/curl.php +++ b/src/Package/Extension/curl.php @@ -16,9 +16,8 @@ class curl #[PatchDescription('Inject secur32.lib into SPC_EXTRA_LIBS for Windows SSPI support')] public function addSecur32LibForWindows(): void { - // libcurl on Windows is always built with CURL_WINDOWS_SSPI=ON (NTLM/SPNEGO/SMB), - // which requires secur32.lib for the SSPI functions. This is independent of the - // selected TLS backend (OpenSSL by default, Schannel via SPC_CURL_TLS_BACKEND). + // libcurl on Windows is built with CURL_WINDOWS_SSPI=ON (NTLM/SPNEGO/SMB), which + // requires secur32.lib for the SSPI functions. $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; if (!str_contains($extra_libs, 'secur32.lib')) { putenv('SPC_EXTRA_LIBS=' . trim("{$extra_libs} secur32.lib")); diff --git a/src/Package/Target/curl.php b/src/Package/Target/curl.php index 7f86766e5..90ca92912 100644 --- a/src/Package/Target/curl.php +++ b/src/Package/Target/curl.php @@ -38,28 +38,6 @@ public function buildWin(LibraryPackage $lib): void $lib_dir = str_replace('\\', '/', $lib->getLibDir()); $zstd_lib = "{$lib_dir}/zstd_static.lib"; $extra_libs = "{$lib_dir}/libcrypto.lib {$lib_dir}/libssl.lib ws2_32.lib gdi32.lib advapi32.lib crypt32.lib user32.lib"; - $schannel_backend_args = [ - '-DCURL_WINDOWS_SSPI=ON', - '-DCURL_USE_SCHANNEL=ON', - '-DCURL_USE_OPENSSL=OFF', - ]; - $ossl_backend_args = [ - // Keep Windows SSPI (NTLM/SPNEGO/SMB) for both TLS backends - '-DCURL_WINDOWS_SSPI=ON', - '-DCURL_USE_SCHANNEL=OFF', - '-DCURL_USE_OPENSSL=ON', - '-DCURL_CA_NATIVE=ON', - '-DCURL_CA_BUNDLE=none', - '-DCURL_CA_PATH=none', - '-DOPENSSL_ROOT_DIR=' . escapeshellarg(str_replace('\\', '/', BUILD_ROOT_PATH)), - '-DOPENSSL_USE_STATIC_LIBS=ON', - ]; - $backend = getenv('SPC_CURL_TLS_BACKEND') ?: 'openssl'; - $backend_args = $backend === 'schannel' ? $schannel_backend_args : $ossl_backend_args; - logger()->info("Building libcurl with TLS backend [{$backend}] (SPC_CURL_TLS_BACKEND)"); - if (!in_array($backend, ['openssl', 'schannel'])) { - logger()->warning("SPC_CURL_TLS_BACKEND can only pass 'schannel' and 'openssl', now fallback to 'openssl'"); - } WindowsCMakeExecutor::create($lib) ->optionalPackage('zstd', ...cmake_boolean_args('CURL_ZSTD')) ->optionalPackage('brotli', ...cmake_boolean_args('CURL_BROTLI')) @@ -78,7 +56,14 @@ public function buildWin(LibraryPackage $lib): void '-DSHARE_LIB_OBJECT=OFF', '-DCURL_USE_LIBSSH2=ON', '-DENABLE_IPV6=ON', - ...$backend_args, + '-DCURL_WINDOWS_SSPI=ON', + '-DCURL_USE_SCHANNEL=OFF', + '-DCURL_USE_OPENSSL=ON', + '-DCURL_CA_NATIVE=ON', + '-DCURL_CA_BUNDLE=none', + '-DCURL_CA_PATH=none', + '-DOPENSSL_ROOT_DIR=' . escapeshellarg(str_replace('\\', '/', BUILD_ROOT_PATH)), + '-DOPENSSL_USE_STATIC_LIBS=ON', ) ->build(); // move libcurl.lib to libcurl_a.lib