cURL error 60: SSL certificate in Laravel 5.4

后端 未结 8 842
有刺的猬
有刺的猬 2020-12-02 20:47

Full Error

RequestException in CurlFactory.php line 187: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see ht

相关标签:
8条回答
  • 2020-12-02 21:27

    I was sending a request from domain X to Y, my problem was with the certificate used on the domain Y (it wasn't a self-signed cert btw), the domain belonged to me & I had the certificate, so the quick fix was to use the domain Y's certificate on domain X's application:

    On domain X:

    • Using Laravel 7 HTTP wrapper:

      \Http::withOptions(['verify' => 'path-to-domain-Y-certificate']);

    • Using guzzle:

      new GuzzleHttp\Client(['verify' => 'path-to-domain-Y-certificate']);

    OR you could just contact your SSL provider to resolve the issue.

    Note: Storing your domain's certificate in another system isn't a secure method, use this method only if you can ensure your certificate's security.

    I haven't found what was wrong with the certificate, no browser seemed to have a problem with it, the only problem was generated on laravel using curl.

    0 讨论(0)
  • 2020-12-02 21:28

    for Laravel: The 5 steps below will be helpful

    • update version to Guzzlehttp: 5.2
    • find the file under \vendor\guzzlehttp\guzzle\src\Client.php
    • edit default settings to

      protected function getDefaultOptions() { $settings = [ 'allow_redirects' => true, 'exceptions' => true, 'decode_content' => true, 'verify' => getcwd() .'/vendor/guzzlehttp/guzzle/src/cacert.pem' ]; }

    • download latest file cacert.pem from http://curl.haxx.se/ca/cacert.pem and place under /vendor/guzzlehttp/guzzle/src/

    0 讨论(0)
  • 2020-12-02 21:31

    I had this problem while running Valet and attempting to make an api from one site in valet to another. Note that i'm working in OSX. I found the solution here: https://github.com/laravel/valet/issues/460 In short you have to copy the valet pem to the system CA bundle. Just run this:

    cp /usr/local/etc/openssl/cert.pem /usr/local/etc/openssl/cert.pem.bak && cat ~/.config/valet/CA/LaravelValetCASelfSigned.pem >> /usr/local/etc/openssl/cert.pem
    
    0 讨论(0)
  • 2020-12-02 21:34

    Another one recently asked for the same problem and it's seems my answer was the solution for him. Here was the post I mention : URL Post

    That's what I said :

    I'll be fully honest, I don't know anything about Laravel. But I had the same problem, so as many other, on Symfony. And so as you I tried many things without success.

    Finally, this solution worked for me : URL solution

    It indicates that instead of a certificate problem, it could came from a environnement non-compatibility. I used XAMPP instead of WAMP and it worked.

    0 讨论(0)
  • 2020-12-02 21:39

    This was stressfull to figure out but here is the exact answer for people using laravel and have this problem.

    My exact application versions are...

    Laravel: 5.4

    Guzzlehttp: 6.2

    Laravel Socialite: 3.0

    Download a fresh copy of this curl certificate from this link: https://gist.github.com/VersatilityWerks/5719158/download

    Save the file in this path starting from the base root of your laravel application vendor/guzzlehttp/guzzle/src/cacert.pem

    next in that same directory open up RequestOptions.php and scroll down to the constant called CERT and change it to this const CERT = 'cacert.pem'; and this should fix it all.

    EDIT

    As people are pointing out you should never edit the vendor folder, this was just a quick fix for an application I was building in my spare time. It wasn't anything majorly important like an application for my company or anything, use this method at your own risk! Please check out the other answers if you need something more concrete.

    0 讨论(0)
  • 2020-12-02 21:42

    Do not ever modify files in the vendor/ folder. Ever. They can and will be overwritten on the next composer update you run.

    Here is my Solution for WampServer

    I am using PHP 7.1.9 for my WampServer, so change 7.1.9 in the example below to the version number you are currently using.

    1. Download this file: http://curl.haxx.se/ca/cacert.pem
    2. Place this file in the C:\wamp64\bin\php\php7.1.9 folder
    3. Open php.iniand find this line:

    ;curl.cainfo

    Change it to:

    curl.cainfo = "C:\wamp64\bin\php\php7.1.9\cacert.pem"

    Make sure you remove the semicolon at the beginning of the line.

    Save changes to php.ini, restart WampServer, and you're good to go!

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