0

When I try to execute a cURL via php on my Linux machine, I get the following error:

SSL certificate problem: certificate has expired

my cacert.pem is the latest version according to https://curl.haxx.se/ca/cacert.pem

I have the following lines in the php.ini file (edited):

[openssl]
;...
openssl.cainfo = /etc/ssl/certs/cacert.pem

;...
openssl.cafile = /etc/ssl/certs/cacert.pem

Details:

  • System: Linux user 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64
  • PHP version: PHP Version 7.0.5-2+deb.sury.org~trusty+1

Btw, I'm pretty much a newbie when it comes to this issues. I'm sure I missed something. I was looking on previous answers in here, and I still couldn't figure it out.

Update 1 - When I use the Postman chrome application, everything is working properly.

Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116

1 Answers1

2

curl uses a different certificates path... try adding this to your php.ini file:

curl.cainfo = "/etc/ssl/certs/cacert.pem"

if you are still having issues, you can try to run curl in "insecure" mode by disabling ssl verification via the CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST settings

Community
  • 1
  • 1
Tony DiFranco
  • 793
  • 5
  • 11
  • Honestly, I tried to do my best to get SSL to work, with no option turned off. In the end, it works with php-fpm but not with php-cli. Something should be missing in php.ini ... So annoying... I disabled it with the parameters CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST. – Antoine Martin Jul 03 '20 at 05:54
  • Tony, Could you tell us where curl is looking for the certificate by default? I'm trying to find this information but every page I search seems to have a different answer. – JamesBB Nov 17 '21 at 16:23