cURL error 1014: SSL verify failed 报错

报错

[ERROR] cURL error 1014: SSL verify failed (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://mgobe.tencentcloudapi.com/[247] in /www/wwwroot/*.net/vendor/
[ERROR] #0 /www/wwwroot/tencentgame.net/vendor/tencentcloud/tencentcloud-sdk-php/src/TencentCloud/Common/AbstractClient.php(175): TencentCloud\Common\AbstractClient->doRequestWithOptions()
#1 /www/wwwroot/*.net/app/Controller/IndexController.php(46): TencentCloud\Common\AbstractClient->__call()
#2 /www/wwwroot/*.net/vendor/hyperf/http-server/src/CoreMiddleware.php(161): App\Controller\IndexController->index()
#3 /www/wwwroot/*.net/vendor/hyperf/http-server/src/CoreMiddleware.php(113): Hyperf\HttpServer\CoreMiddleware->handleFound()

框架

hyperf swoole 4.5.9 openssl1.1.1

方向

1.系统层。swoole的 openssl版本太低。php --ri swoole 查看openssl版本为1.0.1.系统查看openssl version 版本为1.1.1 升级版本swoole的openssl版本。重新编译(行不通)
2.框架问题
hyperf框架swoole采用协程模式,guzzle会造成阻塞报错
根据 https://hyperf.wiki/2.1/#/zh-cn/guzzle

use GuzzleHttp\Client;
use Hyperf\Guzzle\CoroutineHandler;
use GuzzleHttp\HandlerStack;

$client = new Client([
    'base_uri' => 'http://127.0.0.1:8080',
    'handler' => HandlerStack::create(new CoroutineHandler()),
    'timeout' => 5,
    'swoole' => [
        'timeout' => 10,
        'socket_buffer_size' => 1024 * 1024 * 2,
    ],
]);

$response = $client->get('/');

1.在 请求处加入 handler => HandlerStack::create(new CoroutineHandler()) 解决问题
2.直接使用Hyperf\Guzzle\CoroutineHandler 作为处理器设置到 Guzzle 客户端内即可转为协程化运行,为了方便创建协程的 Guzzle 对象,我们提供了一个工厂类 Hyperf\Guzzle\ClientFactory 来便捷的创建客户端

<?php 
use Hyperf\Guzzle\ClientFactory;

class Foo {
    /**
     * @var \Hyperf\Guzzle\ClientFactory
     */
    private $clientFactory;
    
    public function __construct(ClientFactory $clientFactory)
    {
        $this->clientFactory = $clientFactory;
    }
    
    public function bar()
    {
        // $options 等同于 GuzzleHttp\Client 构造函数的 $config 参数
        $options = [];
        // $client 为协程化的 GuzzleHttp\Client 对象
        $client = $this->clientFactory->create($options);
    }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

镜中先生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值