简体   繁体   中英

ssl certificate issue: unable to get local issuer certificate xampp

I'm struck with the same issue which many of them have faced before, hope someone can help me.

I'm getting this error after my client has added SSL certificate to the server.

I've been searching in google and forums the whole day but couldn't fix it so finally i'm posting it here.

My code below :

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_VERBOSE, 1); 
//curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."\cacert.pem");
curl_setopt ($ch, CURLOPT_CAPATH, dirname(__FILE__)."\cacert.pem");
curl_setopt($ch, CURLOPT_STDERR, fopen(dirname(__FILE__)."/curl_debug.txt", "w+"));
if(curl_exec($ch) === false)
{
    echo 'Curl error: ' . curl_error($ch);
}
exit;

I've added these two lines to php.ini file :

[curl]
curl.cainfo="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"

[openssl]
openssl.cafile="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"

And tried downloading the latest cacert.pem file

And tried the above code by giving the absolute path to the file :

//curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."\cacert.pem");

Nothing works, All i get is the same error :

Curl error: SSL certificate problem: unable to get local issuer certificate"

And I added "CURLOPT VERBOSE" to look in detail, below is what I received :

* Hostname in DNS cache was stale, zapped
*   Trying xxx.xxx.x.x...
* Connected to mywebsite.com (xxx.xxx.x.x) port 443 (#0)
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem
  CApath: C:\xampp\htdocs\projects\myproject\includes\cacert.pem
* SSL certificate problem: unable to get local issuer certificate
* Closing connection 0

Note : I added CAPath since it showed CAPath : None , when not specified.

Would be great if anyone could advise me on the above.

Many Thanks

In Windows XAMP, when using CURL I have to set curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); I understand this is some kind of bug.

Obviously this bypasses the verification intended when using SSL so it is a workaround only for development.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM