我正在用laravel做项目。我正在使用plivoapi发送短信。为此,我遵循了上提到的所有步骤
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)'in G:''Xampp''htdocs''plivoTrial''vendor ''guzzlehttp''guzzle ''src''Handler''CurlFactory.php:187堆栈跟踪:#0 G:''Xamp ''htdocs ''plivoTrial'' vendor ''guzzlehttp'' guzzle''src''Handler ''CurlFactory.php(150):guzzlehttp''Handler''CurlFactory::createRejection(对象(guzzlehttp''Handler''EasyHandle),数组)#1 G:''Xampp''htdocs''plivoTrial''vendor''guzzlehttp''guzzle ''src''Handler''CurlFactory.php,对象(GuzzleHttp''Handler''CurlFactory)#2 G:''Xampp''htdocs''plivoTrial''vendor''GuzzleHttp''guzzle ''src''Handler''CurlHandler.php,对象(GuzzleHttp''Handler''CurlFactory))#3 G:''Xampp''htdocs''plivoTria,位于G:''Xamp ''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安装。
这些指示在Windows上对我有效。
当您的CA根证书丢失或过期时,就会出现此问题。由于目前ALLWindows平台PHP安装程序不在发行版中包含CA根证书,因此它在Windows上比在Linux上更常见。
以下是如何更新CA根证书:
- 下载CA根证书的最新副本
- 将文件"cacert.pem"保存到您的计算机中。例如c:''examplep''php
- 将步骤2中的"cacert.pem"文件的位置添加到php.ini文件中
在php.ini文件中搜索[curl]
,并更新或添加以下行:curl.cainfo=c:'xampp'php'cacert.pem
- 重新启动web服务器
Curl现在有一个有效的CA根证书捆绑包,可以验证远程服务器的SSL证书。
如果您在Windows计算机上运行任何Google Cloud Platform PHP示例,您将收到以下cURL错误:CURLE_SSL_CACERT(60)-对等证书无法使用已知的CA证书进行身份验证。这个错误现在应该是不言自明的,以及如何修复它。