SSL certificate problem: unable to get local issuer certificate SOLVED

Console-128

The issue

Today I was trying to consume an external video API for streaming a set of videos; so I got the code for the PHP source, create all my configuration but when I tried to get the actual data from the external server via cURL; I was obtaining nothing; so, in order to get the error’s message, this is what I did:

var_dump(curl_error($ch));

Which basically gets the error after the connection. The message was the following one:

SSL certificate problem: unable to get local issuer certificate

 The solution

1) Download the certificate from http://curl.haxx.se/ca/cacert.pem

2) Create a folder under your home:

mkdir /Users/alex/ssl

3) Copy or move the file with the certificate you just downloaded:

mv /Users/alex/Downloads/cacert.pem /Users/alex/ssl

4) Open your php.ini and look for this directive curl.cainfo  (the path should vary, depending on your system or meta-package you are using: WAMP, XAMPP, AMPPS have different paths).

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo =

5) Type there you path to the certificate; for example in my case, this was the configuration I did:

curl.cainfo = /Users/alex/ssl/cacert.pem

6) Restart your Apache.

7) Enjoy!

 

Leave a Reply

Your email address will not be published. Required fields are marked *