【问题标题】:Why I am getting Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60为什么我收到致命错误:未捕获的异常 'GuzzleHttp\Exception\RequestException' 和消息 'cURL 错误 60
【发布时间】:2016-03-19 18:17:05
【问题描述】:

我在 laravel 做项目。我正在使用 plivo api 发送短信。为此,我遵循了

中提到的所有步骤

https://www.plivo.com/docs/getting-started/send-a-single-sms/

但是当我尝试运行我的 php 文件时,我收到了错误消息

“致命错误:未捕获的异常 'GuzzleHttp\Exception\RequestException' 带有消息 'cURL 错误 60:SSL 证书问题:证书链中的自签名证书(请参阅 http://curl.haxx.se/libcurl/c/libcurl-errors.html)' 在 G:\Xampp\htdocs\plivoTrial\ vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:187 堆栈跟踪:#0 G:\Xampp\htdocs\plivoTrial\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(150): GuzzleHttp\Handler\ CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 G:\Xampp\htdocs\plivoTrial\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory: :finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 G:\Xampp\htdocs\plivoTrial\vendor\guzzlehttp\guzzle\src\Handler \CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(对象(GuzzleHttp\Handler\CurlHandler), 对象(GuzzleHttp\Handler\EasyHandle), 对象(GuzzleHttp\Handler\CurlFactory)) #3 G:\Xampp \htdocs\plivoT ria 在 G:\Xampp\htdocs\plivoTrial\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php 第 187 行。

我的 php 文件看起来像,

<?php
require 'vendor/autoload.php';
use Plivo\RestAPI;

$auth_id = "xxxxxxxxxxxxx";
$auth_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";

$p = new RestAPI($auth_id, $auth_token);

// Set message parameters
$params = array(
'src' => 'xxxxxxxxxxx', 
'dst' => '91xxxxxxxxxx', 
'text' => 'Hi, I am Amarja :)', 
'url' => 'http://localhost/untitled/sentsms.php', 
'method' => 'POST' 
);
// Send message
$response = $p->send_message($params);

echo "Response : ";
print_r ($response['response']);

echo "<br> Api ID : {$response['response']['api_id']} <br>";

echo "Message UUID : {$response['response']['message_uuid'][0]} <br>";

?>

我不知道如何解决这个问题。请帮助并提前非常感谢。

【问题讨论】:

  • 有什么难理解的:证书链中的自签名证书(见curl.haxx.se/libcurl/c/libcurl-errors.html?
  • 其实我之前做过同样的项目。这个新项目在旧项目所在的地方。那个旧项目运行完美,这就是为什么我没有得到问题所在....我认为问题可能与作曲家有关
  • 在你的核心文件中试试curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  • 我在 Plivo 的 plivo.php 文件中试过这个,但仍然显示同样的错误。
  • 是否可以在多个项目中使用auth id和auth token?

标签: php ssl curl laravel-5


【解决方案1】:

不要禁用 SSL

相反,修复您的 PHP 安装

These directions 在 Windows 上为我工作。

当您的 CA 根证书丢失或过期时,就会出现此问题。由于目前 所有 Windows 平台 PHP 安装程序 在发行版中包含 CA 根证书,因此它在 Windows 上比在 Linux 上更常见。

以下是更新 CA 根证书的方法:

  1. Download CA 根证书的最新副本。
  2. 将文件“cacert.pem”保存到您的计算机。例如 c:\xampp\php
  3. 步骤 2 中的“cacert.pem”文件的位置添加到您的 php.ini 文件中。
    在您的 php.ini 文件中搜索 [curl] 并更新或添加以下行:
    curl.cainfo=c:\xampp\php\cacert.pem
  4. 重新启动您的网络服务器。

Curl 现在有一个有效的 CA 根证书包,可以验证远程服务器的 SSL 证书。

如果您在 Windows 计算机上运行任何 Google Cloud Platform PHP examples,您将收到以下 cURL 错误:CURLE_SSL_CACERT (60) - 对等证书无法使用已知 CA 证书进行身份验证。该错误现在应该是不言自明的以及如何修复它。

【讨论】:

  • 有没有办法自动化这个过程?我发现 php 扩展“确定性”可以做到这一点,但需要一个当前的;y 有效的 cacert.pem 才能运行。如何使这些保持最新?
猜你喜欢
  • 2017-07-24
  • 2017-08-31
  • 1970-01-01
  • 2017-07-27
  • 1970-01-01
  • 1970-01-01
  • 2013-08-24
  • 2012-04-25
  • 2021-02-06
相关资源
最近更新 更多