laravel : cURL error 60: SSL certificate unable to get local issuer certificate

依然范特西╮ 提交于 2019-12-23 04:45:31

问题


Ubuntu: 15.04

Laravel: 5.4.32

GuzzleHttp\Guzzle: ~6.0

Hi there

I have the following error when I am trying to reset a password using Laravel's built in authentication. When I enter my email and hit reset I get...

GuzzleHttp\Exceptions\RequestException cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I have googled this error and it from everything I have read I have tried the following, all of which have not worked...

  • Ran phpinfo() to find the correct php.ini
  • Updated the curl.cainfo php.ini settings to "/etc/ssl/certs/cacert.pem"
  • Updated the curl.cainfo php.ini settings to "/etc/ssl/certs/ca-certificated.crt"
  • Updated the openssl.cafile php.ini settings to "/etc/ssl/certs/cacert.pem"
  • Updated the openssl.cafile php.ini settings to "/etc/ssl/certs/ca-certificated.crt"

After each I have restarted apache, however, nothing has worked.

I have also ran var_dump(openssl_get_cert_locations()); which gave me the following...

[
    "default_cert_file" => "/usr/lib/ssl/cert.pem", 
    "default_cert_file_env" => "SSL_CERT_FILE",
    "default_cert_dir" => "/usr/lib/ssl/certs",
    "default_cert_dir_env" => s"SSL_CERT_DIR",
    "default_private_dir" => "/usr/lib/ssl/private",
    "default_default_cert_area" => "/usr/lib/ssl",
    "ini_cafile" => "/etc/ssl/certs/ca-certificates.crt",
    "ini_capath" => "/etc/ssl/certs" ,
]

Can anyone give me some ideas to try? What am I missing?

Thanks


回答1:


Add cacert.pem file in your project, download file from

https://curl.haxx.se/ca/cacert.pem

copy that downloaded the certificate in your /vendor/guzzlehttp/guzzle/src folder. change file Client.php find the function called getDefaultOptions()

replace $settings array with this,

$settings = [
        'allow_redirects' => true,
        'exceptions'      => true,
        'decode_content'  => true,
        //'verify'          => true
        'verify'          => dirname(__FILE__).'/cacert.pem',
];

what I did is for verifying added the downloaded file configuration, just changed the value for verify.

if you want to send curl request insecurely you can disable SSL certificate check, by setting verify => false

Warning: This makes the request absolute insecure




回答2:


I had the similar problem. No need to change /vendor/guzzlehttp/guzzle/src/Client.php

Maybe this can help you.

  1. Download cacert.pem file from https://curl.haxx.se/docs/caextract.html
    Put the cacert.pem somewhere you like.

  2. Edit php.ini

two lines:

curl.cainfo=D:/Servers/php/sslfiles/cacert.pem  
openssl.cafile=D:/Servers/php/sslfiles/cacert.pem  
  1. Restart apache httpd.



回答3:


The problem turned out to be the IT Department had updated the firewall which had, in turn, somehow blocked the server from making requests (this is the opposite from what they told me at the time of posting the question). Once it was allowed to make requests again it worked.



来源:https://stackoverflow.com/questions/46080133/laravel-curl-error-60-ssl-certificate-unable-to-get-local-issuer-certificate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!