CURLOPT_SSL_VERIFYPEER not working in PHP even wit

2019-08-09 15:24发布

问题:

I am trying to enable CURLOPT_SSL_VERIFYPEER in PHP, but when I call curl_exec() it is returning false with no other error message or indication of why its breaking. Here is what I have:

$curl_object = curl_init();
curl_setopt($curl_object, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_object, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl_object, CURLOPT_CAINFO, "/srv/assets/ssl/ca-bundle.pem");
curl_setopt($curl_object, CURLOPT_SSL_VERIFYPEER, true);

curl_setopt($curl_object, CURLOPT_URL, $url);
$response = curl_exec($curl_object);

As soon as I set CURLOPT_SSL_VERIFYPEER to false it works. The CURLOPT_CAINFO file is th offical ca-cert.pem from http://curl.haxx.se/docs/caextract.html.

Any ideas?

回答1:

Maybe this can help to debug the issue:

 curl_setopt($curl, CURLOPT_VERBOSE, 1); 


标签: php curl ssl