我正在使用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)
答案 0 :(得分:2)
就您而言,只需执行此操作
打开你的 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
即。在我的例子中包含 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"
注意:如果 curl.cainfo
未更新,您会收到 cURL 60 错误。如果 openssl.cafile
未更新,则 cURL 77。
另外,不要忘记取消对 ;
和 curl.cainfo
e 之前的 openssl.cafil
的注释。
希望这对某人有所帮助。