cURL 错误 60:SSL 证书:无法获得本地颁发者证书 [英] cURL error 60: SSL certificate: unable to get local issuer certificate

查看:51
本文介绍了cURL 错误 60:SSL 证书:无法获得本地颁发者证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Stripe 发送 API 请求,但收到错误消息:

I am trying to send an API request using Stripe but get the error message:

cURL 错误 60:SSL 证书问题:无法获取本地颁发者证书

cURL error 60: SSL certificate problem: unable to get local issuer certificate

这是我正在运行的代码:

This is the code I am running:

public function chargeStripe()
{
    $stripe = new Stripe;
    $stripe = Stripe::make(env('STRIPE_PUBLIC_KEY'));

    $charge = $stripe->charges()->create([
        'amount'   => 2900,
        'customer' => Input::get('stripeEmail'),
        'currency' => 'EUR',
    ]);

    return Redirect::route('step1');
}

我在谷歌上搜索了很多,很多人建议我下载这个文件:cacert.pem,把它放在某个地方并在我的 php.ini 中引用它.这是我的 php.ini 中的部分:

I searched a lot on Google and lots of people are suggesting that I download this file: cacert.pem, put it somewhere and reference it in my php.ini. This is the part in my php.ini:

curl.cainfo = "C:Windowscacert.pem"

然而,即使在多次重新启动服务器并更改路径后,我仍收到相同的错误消息.

Yet, even after restarting my server several times and changing the path, I get the same error message.

我在 Apache 中启用了 ssl_module,并且在我的 php.ini 中启用了 php_curl.

I have the ssl_module enabled in Apache, and I have php_curl enabled in my php.ini.

我也试过这个修复:如何修复 PHP卷曲错误 60 SSL

这表明我将这些行添加到我的 cURL 选项中:

Which suggests that I add these lines to my cURL options:

curl_setopt($process, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, true);

在哪里向我的 cURL 添加选项?显然不是通过命令行,因为我的 CLI 没有找到命令curl_setopt"

Where do I add options to my cURL? Apparently not through the command line, since my CLI doesn't find the command "curl_setopt"

推荐答案

如何解决这个问题:

  • 按照 cacert.pem"https://curl.se/docs/caextract.html" rel="nofollow noreferrer">https://curl.se/docs/caextract.html

  • download and extract cacert.pem following the instructions at https://curl.se/docs/caextract.html

将其保存在您的文件系统中的某个位置(例如,XAMPP 用户可能使用 C:xamppphpextrassslcacert.pem)

save it on your filesystem somewhere (for example, XAMPP users might use C:xamppphpextrassslcacert.pem)

在你的 php.ini 中,把这个文件位置放在 [curl] 部分(把它放在 [openss] 部分也是一个好主意):

in your php.ini, put this file location in the [curl] section (putting it in the [openss] section is also a good idea):

[curl]
curl.cainfo = "C:xamppphpextrassslcacert.pem"

[openssl]
openssl.cafile = "C:xamppphpextrassslcacert.pem"

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆