gpt4 book ai didi

php - 为什么我在验证 reCAPTCHA 时收到此 "SSL certificate problems: unable to get local issuer certificate"错误?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:40:35 25 4
gpt4 key购买 nike

我在 PHPLaravel 方面都是新手,我遇到了以下奇怪的问题。

我开发了一个包含 Google reCAPTCHA 字段的注册表单,如下所示:

<form method="post" action="/registration">

...............................................................
...............................................................
...............................................................

<div class="form-group">
<label>Captcha</label>
<div class="input-group">
{!! app('captcha')->display(); !!}
</div>
</div>

{{csrf_field()}}

<button type="submit" class="btn btn-default">Submit</button>

</form>

因此,这个领域选择了经典的“我不是机器人”复选框。

如果我只需要选中这个复选框,当表单提交给处理 /registration 资源的 Controller 时我没有问题。

这是处理此请求并验证表单输入的 Controller 方法(带有相关的输入表单验证器):

public function store(Request $request) {

Log::info('store() START');

$data = Input::all();

Log::info('INSERTED DATA: '.implode("|", $data));

$rules = array(
'name' => 'required',
'surname' => 'required',
'login' => 'required',
'email' => 'required|email|confirmed',
//'email_confirmation' => 'required|email|confirmed',
'pass' => 'required|required',
//'passConfirm' => 'required',
'g-recaptcha-response' => 'required|captcha',

);

$validator = Validator::make($data, $rules);

if ($validator->fails()){
return Redirect::to('/registration')->withInput()->withErrors($validator);
}
else{
// Do your stuff.
}
}

如果打开弹出窗口要求选择一些特定的图像,当我提交表单时,我会收到以下错误消息:

RequestException in CurlFactory.php line 187:
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

in CurlFactory.php line 187
at CurlFactory::createRejection(object(EasyHandle), array('errno' => 60, 'error' => 'SSL certificate problem: unable to get local issuer certificate', 'url' => 'https://www.google.com/recaptcha/api/siteverify', 'content_type' => null, 'http_code' => 0, 'header_size' => 0, 'request_size' => 0, 'filetime' => -1, 'ssl_verify_result' => 20, 'redirect_count' => 0, 'total_time' => 0.079000000000000001, 'namelookup_time' => 0.016, 'connect_time' => 0.032000000000000001, 'pretransfer_time' => 0, 'size_upload' => 0, 'size_download' => 0, 'speed_download' => 0, 'speed_upload' => 0, 'download_content_length' => -1, 'upload_content_length' => -1, 'starttransfer_time' => 0, 'redirect_time' => 0, 'redirect_url' => '', 'primary_ip' => '216.58.212.132', 'certinfo' => array(), 'primary_port' => 443, 'local_ip' => '168.202.22.52', 'local_port' => 50542)) in CurlFactory.php line 150

进入到之前的store(Request $request) Controller 方法。我认为问题与此验证设置有关:

'g-recaptcha-response' => 'required|captcha'

因为我认为它会自动调用 Google 服务器来检查验证码(实际上在之前的错误消息中它指定了应该与 Google 相关的 IP:216.58.212.132)。

因此,在网上搜索我发现了与此类错误相关的类似内容:

https://laracasts.com/discuss/channels/general-discussion/curl-error-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate

这基本上是关于必须设置到 Apache 中的 cacert.pem 文件。

就像这样:

I had the exact same but on Windows & xampp. My solution was as simple as: Follow this link: http://curl.haxx.se/ca/cacert.pem Copy the entire page and save it in a: "cacert.pem"

Then in your php.ini file insert or edit the following line: curl.cainfo = "[pathtothisfile]\cacert.pem"

Problem solved

据我所知,这个文件 ( https://curl.haxx.se/ca/cacert-2017-01-18.pem ) 是一组 CA 证书,您可以使用它们来验证服务器是否确实是您正在与之交谈的正确站点。

所以我没有将此文件设置到我的 Apache 中这一事实可能是我的问题的原因吗?

如果是,我需要做些什么来设置它?我不明白我要如何处理这个下载的文件。

最佳答案

关于php - 为什么我在验证 reCAPTCHA 时收到此 "SSL certificate problems: unable to get local issuer certificate"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42394248/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com