我正在使用 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 -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 文件。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"
注意:如果
curl.cainfo
,你会得到 cURL 60 错误没有更新。和 curl 77 如果 openssl.cafile
没有更新。另外,不要忘记取消注释
;
之前 curl.cainfo
和 openssl.cafil
e.希望这可以帮助某人。
关于php - curl 错误 77 : error setting certificate verify locations: CAfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55204210/