Error when using php curl certificate ssl [duplicate]

1

I'm trying to use Curl. The problem is that in some pages it works normally, in others I have the following error:

SSL certificate problem: unable to get local issuer certificate

Here is my code:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.youtube.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($ch);
echo curl_error($ch);
curl_close($ch);
?>

I'm a beginner in php and I also do not understand much about this Curl tool, but what would be the solution to this error?

I'm using Xampp.

    
asked by anonymous 01.03.2016 / 00:56

1 answer

0

Your problem is due to the lack of some parameters needed when performing requests to https page. The correct would be:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.youtube.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$output = curl_exec($ch);
echo curl_error($ch);
curl_close($ch);
?>

I have a class to handle curl, you can see it at this link

    
01.03.2016 / 02:16