swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.42k stars 3.16k forks source link

MacOS(M1/M2)协程 HTTP 客服端报“SSL verify failed” #5130

Closed huangdijia closed 1 week ago

huangdijia commented 1 year ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.
$client = new \Swoole\Coroutine\Http\Client($host = 'www.qq.com', 443, true);
    $client->setHeaders([
        'Host' => $host,
        'User-Agent' => 'Chrome/49.0.2587.3',
        'Accept' => 'text/html,application/xhtml+xml,application/xml',
        'Accept-Encoding' => 'gzip',
    ]);
    $client->set([
        'ssl_verify_peer' => true, // 注释掉这里就正常
        'ssl_allow_self_signed' => true,
        'ssl_host_name' => $host,
    ]);
    $client->get('/');
    var_dump(
        $client->statusCode,
        $client->body,
        $client->errCode,
        $client->errMsg
    );
    $client->close();
  1. What did you expect to see?

返回正常的信息

  1. What did you see instead?

openssl 1.1

int(-1)
string(0) ""
int(1014)
string(17) "SSL verify failed"

openssl 3

 64839 segmentation fault  php test.php
  1. What version of Swoole are you using (show your php --ri swoole)?
php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 5.0.2
Built => Aug 11 2023 10:18:14
coroutine => enabled with boost asm context
kqueue => enabled
rwlock => enabled
openssl => OpenSSL 1.1.1u  30 May 2023
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
zlib => 1.2.12
mysqlnd => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144
  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
uname -a

Darwin MacBook-Air.local 23.0.0 Darwin Kernel Version 23.0.0: Tue Aug  1 03:25:17 PDT 2023; root:xnu-10002.0.242.0.6~31/RELEASE_ARM64_T8103 arm64
php -v

PHP 8.1.22 (cli) (built: Aug  1 2023 16:16:09) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.22, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.22, Copyright (c), by Zend Technologies
gcc -v

Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
leocavalcante commented 1 year ago

If it helps:

Screenshot 2023-08-17 at 11 15 06

Maybe something with ARM arch indeed.

matyhtf commented 1 week ago

php 未安装 openssl,缺少证书导致。