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/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, [' + ); } } diff --git a/src/Package/Extension/curl.php b/src/Package/Extension/curl.php index fc1944913..55618463f 100644 --- a/src/Package/Extension/curl.php +++ b/src/Package/Extension/curl.php @@ -13,11 +13,11 @@ 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 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 66c62490d..90ca92912 100644 --- a/src/Package/Target/curl.php +++ b/src/Package/Target/curl.php @@ -51,14 +51,19 @@ 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', + '-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