It is frustrating to see cURL error 60: SSL certificate problem: self signed certificate in certificate chain error while calling external APIs from your PHP project. Well, the fix is easy. But, sometimes, especially when multiple PHP versions are available in WampServer, extra care should be taken to install it correctly. Follow along:
- Download the latest cacert.pem file.
- Move the file to the desired location. I keep it inside the wamp64 folder. My path to the file is D:/wamp64/cacert.pem
- Now we need to add this path in
php.ini
files located in different folders. 4. Left-click the wampserver icon in the system tray. Select PHP > php.ini. (This file is located inside the Apache folder.) And add the path to curl.cainfo setting as below.
; A default value for the CURLOPT_CAINFO option.
; This is required to be an absolute path.
curl.cainfo="D:/wamp64/cacert.pem"
Don't forget to uncomment the line by removing ; at the beginning of the line.
- Now go to D:/wamp64/bin/php folder. You can see all the available PHP versions. You need to change the same line in two php.ini files. One in the php5.6.40 folder and the other in your latest version / the version you are using.
- Go to php5.6.40 folder and find and open
php.ini
file, change curl.cainfo setting as above. 7. Go to the latest php version, as of this writing, the latest version on my system is 7.4.6. Find and openphp.ini
file, change curl.cainfo setting as above. - Restart the wamp server and you are done.
Originally published on my blog.
Top comments (0)