Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL error 60: SSL certificate prblm: unable to get local issuer certificate [duplicate]

I want to collect a list of videos uploaded on a specific channel using the YouTube data API. However, before implementing online I am trying to get my code running on an offline environment (WAMPserver, PHP 5.5.12, Apache 2.4.9). I am using the following code:

require_once 'google-api-php-client-2.0.0-RC5/vendor/autoload.php';  $client = new Google_Client(); $client->setApplicationName("SRC_Thor"); $client->setDeveloperKey("xxxxxxxxxxx");  $youtube = new Google_Service_YouTube($client);  $channelResponse = $youtube->channels->listChannels('contentDetails', []); var_dump($channelResponse); 

However it gives the following error:

Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)'

I have tried adding the latest version of cacert.pem as most topics on SO offer as a solution, however to no avail.

like image 334
Sjors Hijgenaar Avatar asked Feb 25 '16 21:02

Sjors Hijgenaar


People also ask

What is a Curl Error 60?

Error “curl: (60) SSL certificate problem: unable to get local issuer certificate” can be seen when the SSL certificate on the server is not verified or properly configured.

How do I fix unable to get local issuer certificate?

When ssl certificate problem unable to get local issuer certificate error is caused by a self-signed certificate, the fix is to add the certificate to the trusted certificate store. Open the file ca-bundle. crt located in the directory above, then copy and paste the Git SSL certificate to the end of the file.

Does Curl verify SSL certificate?

libcurl performs peer SSL certificate verification by default. This is done by using a CA certificate store that the SSL library can use to make sure the peer's server certificate is valid.


2 Answers

If you are on Windows using Xampp, I am stealing a better answer from here, would be helpful if Google shows you this question first.

  1. Download and extract for cacert.pem here (a clean file format/data)

    https://curl.haxx.se/docs/caextract.html

  2. Put it in :

    C:\xampp\php\extras\ssl\cacert.pem

  3. Add this line to your php.ini

    curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"

  4. restart your webserver/Apache

like image 73
Phung D. An Avatar answered Sep 29 '22 03:09

Phung D. An


Seeing I am using a local environment I can safely disable SSL, which i did using the following:

$guzzleClient = new \GuzzleHttp\Client(array( 'curl' => array( CURLOPT_SSL_VERIFYPEER => false, ), )); $client->setHttpClient($guzzleClient); 

Where $client is my Google_Client().

like image 37
Sjors Hijgenaar Avatar answered Sep 29 '22 03:09

Sjors Hijgenaar