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

前端 未结 16 2738
时光取名叫无心
时光取名叫无心 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 08:05

    I got the error like :

    failed loading cafile stream: `C:\xamppPhp\apache\bin\curl-ca-bundle.crt`
    

    I am using windows machine. So I followed the below steps.

    1. I have downloaded .pem file from " https://curl.haxx.se/docs/caextract.html "
    
    2. Then I kept the downloaded file inside  "C:/xamppPhp/apache/bin/" folder and renamed the same downloaded file to "curl-ca-bundle.crt".
    
    3. I restarted XAMPP and cleared the cache.
    4. It's done.
    

    Hope it may help someone

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

    Finally got this to work!

    1. Download the certificate bundle.

    2. Put it somewhere. In my case, that was c:\wamp\ directory (if you are using Wamp 64 bit then it's c:\wamp64\).

    3. Enable mod_ssl in Apache and php_openssl.dll in php.ini (uncomment them by removing ; at the beginning). But be careful, my problem was that I had two php.ini files and I need to do this in both of them. One is the one you get from your WAMP taskbar icon, and another one is, in my case, in C:\wamp\bin\php\php5.5.12\

    4. Add these lines to your cert in both php.ini files:

      curl.cainfo="C:/wamp/cacert.pem"
      openssl.cafile="C:/wamp/cacert.pem"
      
    5. Restart Wamp services.

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

    I have a proper solution of this problem, lets try and understand the root cause of this issue. This issue comes when remote servers ssl cannot be verified using root certificates in your system's certificate store or remote ssl is not installed along with chain certificates. If you have a linux system with root ssh access, then in this case you can try updating your certificate store with below command:

    update-ca-certificates

    If still, it doesn't work then you need to add root and interim certificate of remote server in your cert store. You can download root and intermediate certs and add them in /usr/local/share/ca-certificates directory and then run command update-ca-certificates. This should do the trick. Similarly for windows you can search how to add root and intermediate cert.

    The other way you can solve this problem is by asking remote server team to add ssl certificate as a bundle of domain root cert, intermediate cert and root cert.

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

    If you don't have access to php.ini, adding this code (after your $ch = curl_init(); line) works for me:

    $certificate_location = "C:\Program Files (x86)\EasyPHP-Devserver-16.1\ca-bundle.crt"; // modify this line accordingly (may need to be absolute)
    curl_setopt($ch, CURLOPT_CAINFO, $certificate_location);
    curl_setopt($ch, CURLOPT_CAPATH, $certificate_location);
    

    Then, you will just need to download ca-bundle.crt and save it to location you specified in $certificate_location.

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

    The above steps, though helpful, didnt work for me on Windows 8. I don't know the co-relation, but the below steps worked. Basically a change in the cacert.pem file. Hope this helps someone.

    • Download cacert.pem file from here: http://curl.haxx.se/docs/caextract.html
    • Save the file in your PHP installation folder. (eg: If using xampp – save it in c:\Installation_Dir\xampp\php\cacert.pem).
    • Open your php.ini file and add these lines:
    • curl.cainfo=”C:\Installation_Dir\xampp\php\cacert.pem” openssl.cafile=”C:\Installation_Dir\xampp\php\cacert.pem”
    • Restart your Apache server and that should fix it (Simply stop and start the services as needed).
    0 讨论(0)
  • 2020-11-21 08:12

    I have Very Simple Solution of this problem. You can do this without any certificate file..

    Go on Laravel Root Folder -> Vender -> guzzlehttp -> guzzle -> src

    open Client.php

    find $defaults Array . that look like this way ..

    $defaults = [
        'allow_redirects' => RedirectMiddleware::$defaultSettings,
        'http_errors'     => true,
        'decode_content'  => true,
        'verify'          => true,
        'cookies'         => false
    ];
    

    Now main Job is to change value of verify key ..

    'verify'          => false,
    

    So After this it will not check SSL Certificate for CURL Request... This Solution is work for me. I find this solution after many research ...

    0 讨论(0)
提交回复
热议问题