From 4b16631d45a57370b4747df15c8f105130e96d03 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 24 Dec 2024 22:06:31 +0800 Subject: [PATCH] Fix openssl missing cert bug for Linux & macOS (#581) * Fix openssl missing cert bug for linux * Fix openssl missing cert bug for macOS --- src/SPC/builder/linux/library/openssl.php | 1 + src/SPC/builder/macos/library/openssl.php | 2 +- src/globals/ext-tests/openssl.php | 1 + src/globals/test-extensions.php | 6 +++--- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index e427bbf9b..fb3ef045d 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -69,6 +69,7 @@ public function build(): void "{$env} ./Configure no-shared {$extra} " . '--prefix=/ ' . '--libdir=lib ' . + '--openssldir=/etc/ssl ' . '-static ' . "{$zlib_extra}" . 'no-legacy ' . diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index 54ebe975c..d05d2a3da 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -54,7 +54,7 @@ protected function build(): void "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . - '--openssldir=/System/Library/OpenSSL ' . + '--openssldir=/etc/ssl ' . "darwin64-{$this->builder->getOption('arch')}-cc" ) ->exec('make clean') diff --git a/src/globals/ext-tests/openssl.php b/src/globals/ext-tests/openssl.php index 28e586f98..8c42202db 100644 --- a/src/globals/ext-tests/openssl.php +++ b/src/globals/ext-tests/openssl.php @@ -4,3 +4,4 @@ assert(function_exists('openssl_digest')); assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e'); +assert(file_get_contents('https://example.com/') !== false); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 8a15e818b..6836cc8b2 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -35,12 +35,12 @@ $upx = false; // prefer downloading pre-built packages to speed up the build process -$prefer_pre_built = true; +$prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'imagick', - 'Windows' => 'zlib', + 'Linux', 'Darwin' => 'openssl', + 'Windows' => 'openssl', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).