php - laravel 5.7 cURL 错误 60 : SSL certificate problem: unable to get local issuer certificate

标签 php laravel ssl wamp

我正在为 laravel 5.7 使用这个包

composer require ipecompany/smsirlaravel

我的所有链接都工作正常,但包管理面板链接给出了 ssl 错误。 我尝试下载 cacert.pem 文件并将其放在

C:\wamp64\bin\php\php7.1.9\extras\ssl\cacert.pem

C:\wamp64\bin\apache\apache2.4.27\bin\cacert.pem

但还没有遇到这个错误

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

我正在使用 wamp 3.1.0 和 php 版本 7.1.9,所以知道如何解决这个错误吗??

最佳答案

尝试禁用检查:

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

更新

好的,对不起,我的错,没有注意到您正在使用外部包。此软件包使用 Guzzle,要在 Guzzle 中禁用此检查,您需要添加 this option .

作为一个选项,您需要创建自己的类并扩展此 Ipecompany\Smsirlaravel\Smsirlaravel 类并覆盖方法。不好的是,在此类的每个方法中,类都会创建 GuzzleClient 的新实例,因此您需要重写所有方法...我建议将字段添加到您的类 $client 并在构造函数中创建它:

<?php

namespace App\Vendors\Smsirlaravel;

use Ipecompany\Smsirlaravel\Smsirlaravel;
use GuzzleHttp\Client;

class SendSmsIr extends Smsirlaravel {
  protected $client;

  public function __construct()
  {
    $this->client = new Client(['verify' => config('smsirlaravel.ssl_verify')]);
  }

  /** other methods */
}

config/smsirlaravel.php 中将这一行添加到数组中

'ssl_verify' => false,//true, false 或证书路径 '/path/to/cert.pem'

关于php - laravel 5.7 cURL 错误 60 : SSL certificate problem: unable to get local issuer certificate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54400051/

相关文章:

c#,如何存储和检查生成的许可证 key ?

mysql - 通过 ssl 连接到 mysql 的最佳 Node.js mysql 模块是什么?

php - Laravel 中调用未定义函数 App\Http\Controllers\now()

android - Android 4.4 及更低版本上的 SSLHandshakeException

php - 从 Laravel 查询构建器中获取具有 elquent 关系的数据

php - require_once(../../path/to/script.php) 无法打开流权限被拒绝

php - 从 MySQL 结果中消除重复数据

php - 为什么 PHP/WordPress 在这里回显空行?

laravel - 如何在 Javascript 中将对象数组转换为 GraphQL 格式?

Javascript 不响应点击事件 [Laravel 5.5]