2023-07-28 23:47:22 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
|
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('openssl')]
|
|
|
|
|
class openssl extends Extension
|
|
|
|
|
{
|
|
|
|
|
public function patchBeforeMake(): bool
|
|
|
|
|
{
|
2025-07-19 15:10:42 +07:00
|
|
|
$patched = parent::patchBeforeMake();
|
2023-07-28 23:47:22 +08:00
|
|
|
// patch openssl3 with php8.0 bug
|
2024-07-09 18:20:27 +08:00
|
|
|
if ($this->builder->getPHPVersionID() < 80100) {
|
2023-07-28 23:47:22 +08:00
|
|
|
$openssl_c = file_get_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c');
|
|
|
|
|
$openssl_c = preg_replace('/REGISTER_LONG_CONSTANT\s*\(\s*"OPENSSL_SSLV23_PADDING"\s*.+;/', '', $openssl_c);
|
|
|
|
|
file_put_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c', $openssl_c);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-09-30 08:56:37 +02:00
|
|
|
|
2025-07-19 15:10:42 +07:00
|
|
|
return $patched;
|
2023-07-28 23:47:22 +08:00
|
|
|
}
|
2023-10-27 18:22:43 +02:00
|
|
|
|
2025-03-27 11:12:19 +07:00
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
2023-10-27 18:22:43 +02:00
|
|
|
{
|
2025-03-07 18:25:19 +08:00
|
|
|
$openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH;
|
2025-07-30 23:02:28 +08:00
|
|
|
$args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir;
|
2025-08-03 22:59:40 +08:00
|
|
|
if ($this->builder->getPHPVersionID() >= 80500 || !$this->builder->getOption('enable-zts')) {
|
2025-07-30 23:02:28 +08:00
|
|
|
$args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"';
|
|
|
|
|
}
|
|
|
|
|
return $args;
|
2023-10-27 18:22:43 +02:00
|
|
|
}
|
2025-07-30 23:23:12 +08:00
|
|
|
|
|
|
|
|
public function getWindowsConfigureArg(bool $shared = false): string
|
|
|
|
|
{
|
|
|
|
|
$args = '--with-openssl';
|
2025-07-31 00:11:49 +08:00
|
|
|
if ($this->builder->getPHPVersionID() >= 80500) {
|
2025-07-30 23:23:12 +08:00
|
|
|
$args .= ' --with-openssl-argon2';
|
|
|
|
|
}
|
|
|
|
|
return $args;
|
|
|
|
|
}
|
2023-07-28 23:47:22 +08:00
|
|
|
}
|