PHP - SSL certificate error: unable to get local issuer certificate

前端 未结 16 2731
时光取名叫无心
时光取名叫无心 2020-11-21 07:49

I\'m running PHP Version 5.6.3 as part of XAMPP on Windows 7.

When I try to use the Mandrill API, I\'m getting the following error:

Uncaught e

相关标签:
16条回答
  • 2020-11-21 07:54

    When you view the http://curl.haxx.se/docs/caextract.html page, you will notice in big letters a section called:

    RSA-1024 removed

    Read it, then download the version of the certificates that includes the 'RSA-1024' certificates. https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt

    Those will work with Mandrill.

    Disabling SSL is a bad idea.

    0 讨论(0)
  • 2020-11-21 07:55

    for guzzle you can try this :

    $client = new Client(env('API_HOST'));
    $client->setSslVerification(false);
    

    tested on guzzle/guzzle 3.*

    0 讨论(0)
  • 2020-11-21 07:57

    I was facing a problem like this in my local system but not in the live server. I also mentioned another solution on this page its before, but that was not working in localhost.so find a new solution of this, that is working in the localhost-WAMP Server.

    cURL Error #:SSL certificate problem: unable to get local issuer certificate

    sometimes system could not find your cacert.pem in your drive. so you can define this in your code where you are going to use CURL

    Note that i am fulfilling all conditions for this like OPEN-SSL library active and other things.

    check this code of CURL.

     $curl = curl_init();
     curl_setopt_array($curl, array(
                CURLOPT_URL =>$url,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_CUSTOMREQUEST => "GET",
                CURLOPT_RETURNTRANSFER=> true,
            ));
    curl_setopt($curl, CURLOPT_CAINFO, "f:/wamp/bin/cacert.pem"); // <------ 
    curl_setopt($curl, CURLOPT_CAPATH, "f:/wamp/bin/cacert.pem"); // <------
    $response = json_decode(curl_exec($curl),true);
    $err = curl_error($curl);
    curl_close($curl);
    

    but this solution may not work in live server. because of absolute path of cacert.pem

    0 讨论(0)
  • 2020-11-21 07:58

    If none of the solutions above are working for you try updating your XAMPP installation to a newer version.

    I was running XAMPP with php 5.5.11, the same exact code didn't work, I upgraded to XAMPP with php 5.6.28 and the solutions above worked.

    Additionally only updating PHP didn't work either seems like a combination of apache and php settings on that version of XAMPP.

    Hope it helps someone.

    0 讨论(0)
  • 2020-11-21 08:04

    Disclaimer: This code makes your server insecure.

    I had the same problem in Mandrill.php file after line number 65 where it says $this->ch = curl_init();

    Add following two lines:

    curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
    

    This solved my problem and also sent email using localhost but I suggest to NOT use it on live version live. On your live server the code should work without this code.

    0 讨论(0)
  • 2020-11-21 08:04

    I tried this it works

    open

    vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php
    

    and change this

     $conf[CURLOPT_SSL_VERIFYHOST] = 2;
     `enter code here`$conf[CURLOPT_SSL_VERIFYPEER] = true;
    

    to this

    $conf[CURLOPT_SSL_VERIFYHOST] = 0;
    $conf[CURLOPT_SSL_VERIFYPEER] = FALSE;
    
    0 讨论(0)
提交回复
热议问题