php 如何解决 cURL 错误 60:Laravel 5 中的 SSL 证书而 Facebook 身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30974869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:09:47  来源:igfitidea点击:

How to solve cURL error 60: SSL certificate in Laravel 5 while Facebook authentication

phpfacebooksslcurllaravel-5

提问by Nilesh

Currently, I am doing a project on laravel5.

目前,我正在 Laravel5 上做一个项目。

I use socialize for Facebook authentication,But I got cURL error Mentioned below.

我使用社交进行 Facebook 身份验证,但我遇到了下面提到的 cURL 错误。

 RequestException in CurlFactory.php line 162:
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I have searched on internet and done following changes but didn't helped

我在互联网上搜索并做了以下更改但没有帮助

  • downloaded cart.pem file
  • set path "curl.cainfo ="C:\xampp\cacert.pem"
  • also uncomment "extension=php_curl.dll"
  • 下载的cart.pem文件
  • 设置路径 "curl.cainfo ="C:\xampp\cacert.pem"
  • 也取消注释“extension=php_curl.dll”

My code of in controller

我的控制器代码

public function fb()  
{
    return Socialize::with('facebook')->redirect();
}
public function cb()    //callback for facebook
{
    $user = Socialize::with('facebook')->user();
    var_dump($user);
}

回答by Curos

https://laracasts.com/discuss/channels/general-discussion/curl-error-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate

https://laracasts.com/discuss/channels/general-discussion/curl-error-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate

https://laracasts.com/discuss/channels/general-discussion/curl-error-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate/replies/52954

https://laracasts.com/discuss/channels/general-discussion/curl-error-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate/replies/52954

I just spent a number of hours grappling with this. The correct answer is

"indeed to put the cacert.pem file and amend the php.ini file to match as suggested by Moez above. ..... but I kept on getting CURL error 60's The trick was getting a clean copy of the PEM file! Any method involving windows notepad or other editors corrupts the file and gives the cURL error 60 etc. Finally I found https://gist.github.com/VersatilityWerks/5719158/downloadand downloaded a tar file with a clean copy of the cacert.pem file ...... it then all worked perfectly."

我只是花了几个小时来解决这个问题。正确答案是

“确实把 cacert.pem 文件并修改 php.ini 文件以匹配上面 Moez 的建议......但我一直收到 CURL 错误 60's 诀窍是获得 PEM 文件的干净副本!任何涉及 Windows 记事本或其他编辑器的方法会损坏文件并给出 cURL 错误 60 等。最后我找到了https://gist.github.com/VersatilityWerks/5719158/download并下载了一个带有 cacert.pem 干净副本的 tar 文件文件......然后一切正常。”

And since you are working on Windows, this could be the problem.

而且由于您在 Windows 上工作,这可能是问题所在。

回答by Olufemi Ayodele

While on local-host with Laravel you can easily bypass cURL error.

在使用 Laravel 的本地主机上,您可以轻松绕过 cURL 错误。

navigate to Client.php file (vendor\guzzlehttp\guzzle\src\Client.php)

导航到 Client.php 文件 (vendor\guzzlehttp\guzzle\src\Client.php)

Change "verify" to false

将“验证”更改为假

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

回答by Hashmat Waziri

Windows : php.inienter image description here

视窗:php.ini在此处输入图片说明

and worked fine

并且工作正常

回答by Matt Rabe

For anyone pulling their hair out saying "I'VE DOWNLOADED A PRISTINE cacert.pem FILE, PUT IT IN THE CORRECT LOCATION, SET curl.cainfo CORRECTLY, AND RESTARTED MY APACHE SERVER BUT IT JUST DOESN'T WORK!?!?"... If you're using php-fpm then service apache2 restartand service apache2 reloadwill notupdate the reference and you'll continue to get error 60. If you intentionally point curl.cainfo to a bad path, you will not get the expected error 77 (first clue).

对于任何人都说“我已经下载了一个原始的 cacert.pem 文件,把它放在正确的位置,正确地设置 curl.cainfo,然后重新启动我的 APACHE 服务器,但它根本不起作用!?!?”。 ..如果你正在使用PHP-FPM然后service apache2 restartservice apache2 reload不会更新引用,你会继续得到错误60.如果您有意指向curl.cainfo一个坏的路径,你就不会得到预期的错误77(第一条线索)。

To restart php-fpm and update that reference (without rebooting the whole server), use service php-fpm restartor service php5-fpm restartor service php7-fpm restartor service php7.0-fpm restart, etc, depending on your php version. Hope this helps save someone time.

要重新启动 php-fpm 并更新该引用(无需重新启动整个服务器),请使用service php-fpm restartorservice php5-fpm restartservice php7-fpm restartorservice php7.0-fpm restart等,具体取决于您的 php 版本。希望这有助于节省某人的时间。

回答by Fillz Adebayo

well it may sometimes be confusing. when you check the php.inifile you will see ;curl.cainfo = “certificate path\cacert.pem”you have to note there is a semicolon in front. remove that and all the quotes marks, and simple put the file path to look like this curl.cainfo = C:\xampp\php\extras\ssl\cacert.pemas you can see my cacert.pemis in the path C:\xampp\php\extras\ssl\cacert.pem thats where it should be . save and restart your server.

好吧,它有时可能会令人困惑。当您检查php.ini文件时,您会看到;curl.cainfo = “certificate path\cacert.pem”您必须注意前面有一个分号。删除它和所有引号,然后简单地将文件路径设置为如下所示, curl.cainfo = C:\xampp\php\extras\ssl\cacert.pem因为您可以看到我cacert.pem的位于路径 C:\xampp\php\extras\ssl\cacert.pem 应该在的位置。保存并重新启动您的服务器。