cURL 错误 77:设置证书验证位置时出错:CAfile

2024-05-17

我正在使用 Firebase php SDKlink https://firebase-php.readthedocs.io/en/latest/index.html并在 Windows 10 上的 XAMPP 服务器上使用 laravel 最新版本,但是当我尝试使用上述 php SDK 使用 Firebase APi 时,出现此错误。我手动下载 .pem 证书,但仍然无法正常工作

Error

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=

with

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

对于其他可能遇到此错误的人,请按照以下步骤操作:

这与您的 cURL 认证有关。采取以下步骤:

  1. 前往http://curl.haxx.se/ca/cacert.pem。此链接可让您(下载)最新的 cacert.pem 文件。

  2. 在您当前正在使用的应用程序的终端上使用此命令,这样您就可以知道在计算机上多次安装 PHP 的情况下使用的确切 PHP,php -i | grep 'Configuration File'。这会显示当前正在运行的应用程序的 php.ini 文件的确切位置。例如,我的是C:\php-7.4.11\php.ini。请注意此位置,因为我们很快就会使用它。

  3. 进入这个位置C:\php-7.4.11IE。在我的例子中包含 php.ini 文件的文件夹,打开“extras”,打开“ssl”(为了清楚起见,我的看起来像这样C:\php-7.4.11\extras\ssl)。在此文件夹中,粘贴在上面步骤 1 中新下载的 cacert.pem 文件。

  4. 右键单击 cacert.pem 文件并从“属性”中取消阻止它,因为它可能会抱怨来自另一台计算机。仍然在此属性部分弹出窗口中,从“安全”部分复制新文件位置链接(我的是C:\php-7.4.11\extras\ssl\cacert.pem确保复制您的)。您还可以从文件浏览器标头复制此内容。

  5. 转到这个位置C:\php-7.4.11\php.ini(这是我的 php.ini 位置。转到您的位置)并更新 php.ini 文件中的以下 2 个字段。

    ;curl.cainfo =

    ;openssl.cafile=

with

curl.cainfo ="C:\php-7.4.11\extras\ssl\cacert.pem"

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

注意:如果出现以下情况,您会收到 cURL 60 错误curl.cainfo没有更新。和 cURL 77 如果openssl.cafile没有更新。

另外,不要忘记取消注释; before curl.cainfo and openssl.cafile.

希望这对某人有帮助。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

cURL 错误 77:设置证书验证位置时出错:CAfile 的相关文章

随机推荐