我正在用 laravel 做项目。我正在使用 plivo api 发送短信。为此,我遵循了以下提到的所有步骤
https://www.plivo.com/docs/getting-started/send-a-single-sms/ 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 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(对象(GuzzleHttp\Handler\CurlHandler), 对象(GuzzleHttp\Handler\EasyHandle), 对象(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\plivoTria 在 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>";
?>
我不知道如何解决这个问题。请帮忙,非常感谢。
不要禁用 SSL
反而,修复你的 PHP 安装.
这些方向 https://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/在 Windows 上为我工作。
当您的 CA 根证书丢失或过期时,就会出现此问题。既然此刻ALLWindows 平台 PHP 安装程序DO NOT在发行版中包含 CA 根证书,它在 Windows 上比在 Linux 上更常见。
以下是更新 CA 根证书的方法:
-
Download https://curl.haxx.se/docs/caextract.htmlCA 根证书的最新副本。
- 将文件“cacert.pem”保存到您的计算机。例如c:\xampp\php
- 添加“cacert.pem”文件的位置Step 2给你的php.ini file.
搜索[curl]
在你的php.ini文件并更新或添加以下行:
curl.cainfo=c:\xampp\php\cacert.pem
- 重新启动您的网络服务器。
Curl 现在拥有有效的 CA 根证书捆绑包,并且可以验证远程服务器的 SSL 证书。
如果您正在运行任何Google 云平台 PHP 示例 https://cloud.google.com/php/getting-started/using-cloud-datastore在 Windows 计算机上,您将收到以下 cURL 错误:CURLE_SSL_CACERT (60) https://curl.haxx.se/libcurl/c/libcurl-errors.html#CURLESSLCACERT- 对等证书无法使用已知的 CA 证书进行身份验证。现在,该错误以及如何修复它应该是不言自明的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)