cURL error 60: SSL certificate problem: self signed certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
-
The curl request is failing. I normally just go to http://curl.haxx.se/ca/cacert.pem & download it in the php directory. Then add it to php.ini
curl.cainfo="C:\laragon\bin\php\php-7.0.10-Win32-VC14-x86\cacert.pem"
Restart the server.
That's not working in Laragon anymore?
-
@dragonfire1119 : I'll check and respond to you soon.
-
@dragonfire1119 : I'm not sure what did you do but it works for me.
- Download http://curl.haxx.se/ca/cacert.pem and put it to etc\ssl\cacert.pem
- Update php.ini
[curl] ; A default value for the CURLOPT_CAINFO option. This is required to be an ; absolute path. ;curl.cainfo = curl.cainfo = "C:\laragon\etc\ssl\cacert.pem"
- Reload the Web Server
That's all.
-
Quick test:
curl.php<?php $curl = curl_init(); $url = 'https://twitter.com'; curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec ($curl); var_dump($buffer); curl_close ($curl);
-
@leokhoa said:
<?php
$curl = curl_init();
$url = 'https://twitter.com';
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec ($curl);
var_dump($buffer);
curl_close ($curl);The twitter works but what about posting to a localhost site on laragon https://test.dev? When I do that it gives me
cURL Error #:SSL certificate problem: self signed certificate
-
@dragonfire1119 : This link may help:
http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
-
Could it be something with Nginx? Stopping the cainfo from working? The blog post is just saying that curl doesn't trust the self signed certificate but normally it works for me with putting the cacert.pem in.
-
I don't think it's related to Nginx (but maybe Apache with mod_php works)
For testing, you can put
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Although, it is not a proper way and not recommend but you can use it temporarily in dev.
-
I changed to Apache & it works. Seems that Nginx doesn't work with cainfo in php.ini. I can't find anything on the internet about it. I guess not many people are running nginx on a dev environment?
I couldn't even get the verify false on guzzle to work on Nginx.
I don't understand why it doesn't work.