5

I am doing project in laravel. I am using plivo api for sending sms. For that I followed all the steps mentioned at

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

but When I tried to run my php file then I am getting error message as

"Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in G:\Xampp\htdocs\plivoTrial\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:187 Stack trace: #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(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #3 G:\Xampp\htdocs\plivoTria in G:\Xampp\htdocs\plivoTrial\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187".

My php file looks like,

<?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>";

?>

I am not getting how to solve this problem. please help and many thanks in advance.

AmarjaPatil4
  • 1,640
  • 3
  • 28
  • 41
  • Whats hard to understand about: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html ? – Quentin Dec 14 '15 at 10:23
  • Actually I did same project before. This new project is at a place where the old one is. That old project runs perfectly, thats why I am not getting what the issue is....I think problem might be related to the composer – AmarjaPatil4 Dec 14 '15 at 10:32
  • try it with `curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);` in your core file – Chetan Ameta Dec 14 '15 at 10:35
  • I tried this in Plivo's plivo.php file but still it shows same error. – AmarjaPatil4 Dec 14 '15 at 10:40
  • Is it possible to use auth id and auth token in more than one project? – AmarjaPatil4 Dec 15 '15 at 05:31

1 Answers1

11

Do not disable SSL

Instead, fix your PHP installation.

These directions worked for me on Windows.

This problem shows up when your CA root certificates are missing or out-of-date. Since at the moment ALL the Windows platform PHP installers DO NOT include the CA root certificates in the distribution, its much more common on Windows than on Linux.

Here is how you update the CA root certificates:

  1. Download an up-to-date copy of CA root certificates.
  2. Save the file "cacert.pem" to your computer. For example c:\xampp\php
  3. Add the location of the "cacert.pem" file from Step 2 to your php.ini file.
    Search for [curl] in your php.ini file and update or add the following line:
    curl.cainfo=c:\xampp\php\cacert.pem
  4. Restart your web server.

Curl now has a valid CA root certificate bundle and can verify the SSL certificates of remote servers.

If you are running any of the Google Cloud Platform PHP examples on a Windows computer you'll get the following cURL error : CURLE_SSL_CACERT (60) - Peer certificate cannot be authenticated with known CA certificates. That error should now be self-explanatory along with how to fix it.

Andre F
  • 423
  • 4
  • 11
  • 1
    Is there a way to automate this process? I found the php extension "certainty" does this, but requires a current;y valid cacert.pem to run. What cna be done to keep these up-to-date? – Richard Duerr Oct 18 '18 at 15:05