php - curl 错误 77 : error setting certificate verify locations: CAfile

标签 php laravel firebase

我正在使用 Firebase php SDK link并在 Windows 10 上的 XAMMP 服务器上使用 laravel 最新版本,但是当我尝试使用上面的 php SDK 使用 Firebase API 时,我收到此错误。我手动下载 .pem 证书但仍然无法正常工作

错误

Kreait \ Firebase \ Exception \ ApiException
cURL error 77: error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Previous exceptions
cURL error 77: error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) (0)

最佳答案

在您的情况下,只需执行此操作
打开你的 php.ini 文件并更新它

;openssl.cafile=
openssl.cafile="C:\xampp\apache\bin\curl-ca-bundle.crt"

对于可能面临此错误的其他人,请按照以下步骤操作:
这与您的 cURL 认证有关。采取以下步骤:
  • 前往 http://curl.haxx.se/ca/cacert.pem .此链接为您提供(下载)最新的 cacert.pem 文件。
  • 在您当前正在处理的应用程序的终端上使用此命令,以便您知道在您的计算机上多次安装 PHP 时使用的确切 PHP,php -i | grep 'Configuration File' .这会显示您正在运行的当前应用程序的 php.ini 文件的确切位置。例如,我的是 C:\php-7.4.11\php.ini .请注意此位置,因为我们将很快使用它。
  • 进入这个位置C:\php-7.4.11 IE。在我的例子中包含 php.ini 文件的文件夹,打开“extras”,打开“ssl”(为了清楚起见,我的看起来像这样 C:\php-7.4.11\extras\ssl )。在此文件夹中,粘贴上面步骤 1 中新下载的 cacert.pem 文件。
  • 右键单击 cacert.pem 文件并从“属性”中取消阻止它,因为它可能会提示来自另一台计算机。仍然在此属性部分弹出窗口中,从“安全”部分复制新文件位置链接(我的是 C:\php-7.4.11\extras\ssl\cacert.pem 确保复制您的)。您也可以从文件浏览器标题中复制它。
  • 转到此位置 C:\php-7.4.11\php.ini (这是我的 php.ini 位置。转到您的位置)并更新 php.ini 文件中的以下 2 个字段。
    ;curl.cainfo =
    ;openssl.cafile=

  • curl.cainfo ="C:\php-7.4.11\extras\ssl\cacert.pem"
    
    openssl.cafile="C:\php-7.4.11\extras\ssl\cacert.pem"
    
  • 重新启动您的 xampp/wamp 服务器。就我而言,我还重新启动了所有其他正在运行的服务器。

  • 注意:如果 curl.cainfo,你会得到 cURL 60 错误没有更新。和 curl 77 如果 openssl.cafile没有更新。
    另外,不要忘记取消注释 ;之前 curl.cainfoopenssl.cafil e.
    希望这可以帮助某人。

    关于php - curl 错误 77 : error setting certificate verify locations: CAfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55204210/

    相关文章:

    php - 如何使用 PHP 增加 MySQL 数据库中的某些行?

    php - 来自 HTML(和 jQuery)的连续 Ajax 调用

    laravel - 寻找一种简单的方法来跳过 Blade 模板中 undefined variable

    javascript - laravel5.3 中带有图像上传的 Laravel 表单

    twitter-bootstrap - 如何在 Laravel 模板中使用 Bootstrap

    android - 升级到最新的 android/firebase sdk,这个 azure 通知中心示例 - xamarin forms

    php - 更改数据库记录排序顺序以使用 PHP 在其他记录之间移动记录位置

    javascript - 在ajax中获取多个复选框值到php

    java - 如何从 Firebase 获取特定键的特定子值

    javascript - Geofirestore 文档