我正在为 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/