Fix patch, use pure socket client directly

This commit is contained in:
crazywhalecc 2025-08-03 01:23:47 +08:00
parent e6cf05ddff
commit e7fe91faef
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 18 additions and 6 deletions

View File

@ -87,10 +87,11 @@ class SourcePatcher
} }
// patch configure.ac // patch configure.ac
$musl = SPCTarget::getLibc() === 'musl';
FileSystem::replaceFileStr( FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/configure.ac', SOURCE_PATH . '/php-src/configure.ac',
'if command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1', 'if command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1',
'if [ "$SPC_LIBC" = "musl" ];' 'if ' . ($musl ? 'true' : 'false')
); );
if (getenv('SPC_LIBC') === false && ($libc = SPCTarget::getLibc()) !== null) { if (getenv('SPC_LIBC') === false && ($libc = SPCTarget::getLibc()) !== null) {
putenv("SPC_LIBC={$libc}"); putenv("SPC_LIBC={$libc}");

View File

@ -6,14 +6,25 @@ assert(function_exists('openssl_digest'));
assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e'); assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e');
if (file_exists('/etc/ssl/openssl.cnf')) { if (file_exists('/etc/ssl/openssl.cnf')) {
$domain_list = [ $domain_list = [
'https://captive.apple.com/', 'captive.apple.com',
'https://detectportal.firefox.com/', 'detectportal.firefox.com',
'https://static-php.dev/', 'static-php.dev',
'https://www.example.com/', 'www.example.com',
]; ];
$valid = false; $valid = false;
foreach ($domain_list as $domain) { foreach ($domain_list as $domain) {
if (file_get_contents($domain) !== false) { $ssloptions = [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => true,
'allow_self_signed' => false,
'CN_match' => $domain,
'verify_peer' => true,
'SNI_enabled' => true,
'SNI_server_name' => $domain,
];
$context = stream_context_create(['ssl' => $ssloptions]);
$result = stream_socket_client("ssl://{$domain}:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if ($result !== false) {
$valid = true; $valid = true;
break; break;
} }