Windows PHP cURL SSL connection response false, and the .pem file from outer space

Photo by Greg Rakozy on Unsplash

Windows PHP cURL SSL connection response false, and the .pem file from outer space

If you are trying to stablish an SSL connection using PHP cURL from windows, check that you have a file named "cacert.pem" on your PC, you can download it from the following link:

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

You may put it on "your php installation path"\extras\ssl ie.

Then go to the php.ini and edit the section under [curl], it originally looks something like this:

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

remove the comment from ;curl.cainfo and set value corresponding to the path where the cacert.pem file is stored, like this:

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "<path where you stored your pem file>/cacert.pem"

Save it, if you are using a web server, restart it.

That's it.

Vires acquirit eundo!