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
$musl = SPCTarget::getLibc() === 'musl';
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/configure.ac',
'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) {
putenv("SPC_LIBC={$libc}");

View File

@ -6,14 +6,25 @@ assert(function_exists('openssl_digest'));
assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e');
if (file_exists('/etc/ssl/openssl.cnf')) {
$domain_list = [
'https://captive.apple.com/',
'https://detectportal.firefox.com/',
'https://static-php.dev/',
'https://www.example.com/',
'captive.apple.com',
'detectportal.firefox.com',
'static-php.dev',
'www.example.com',
];
$valid = false;
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;
break;
}