laravel 为什么我在验证 reCAPTCHA 时收到此“SSL 证书问题:无法获得本地颁发者证书”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42394248/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why I am obtaining this "SSL certificate problems: unable to get local issuer certificate" error validating a reCAPTCHA?
提问by
I am pretty new in PHPand moreover in Laraveland I have the following strange problem.
我对PHP和Laravel 还很陌生,我有以下奇怪的问题。
I have developed witha registration form containing a Google reCAPTCHAfield, something like this:
我开发了一个包含 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>
So this field shoe the classic "I am not a robot"checkbox.
所以这个领域鞋经典的“我不是机器人”复选框。
If I have only to check this checkbox I have no problem when the form is submitted to the controller handling the /registrationresource.
如果我只需要选中这个复选框,当表单提交给处理/registration资源的控制器时,我没有问题。
This is the controller method (with the related input form validator) that hande this request and that validate the form input:
这是处理此请求并验证表单输入的控制器方法(带有相关的输入表单验证器):
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.
}
}
If instead is opened the popup asking to chose some specific images, when I submit the form I obtain the following error message:
如果打开弹出窗口要求选择某些特定图像,则当我提交表单时,我会收到以下错误消息:
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
It enter into the previous store(Request $request)controller method. I think that the problem is related to this validation setting:
它进入之前的store(Request $request)控制器方法。我认为问题与此验证设置有关:
'g-recaptcha-response' => 'required|captcha'
because I think that it automatially does a call toward the Google Server to check the captcha (infact in the previous error message it specify this IP that should be related to Google: 216.58.212.132).
因为我认为它会自动调用谷歌服务器来检查验证码(事实上在之前的错误消息中它指定了应该与谷歌相关的 IP:216.58.212.132)。
So, searching online I found something like this related to this kind of error:
因此,在网上搜索我发现了与此类错误相关的类似内容:
that basically speack abot a cacert.pemfile that have to be setted into Apache.
这基本上是说必须设置到Apache 中的cacert.pem文件。
It sasy something like this:
它是这样的:
I had the exact same but on Windows & xampp. My solution was as simple as: Follow this link: http://curl.haxx.se/ca/cacert.pemCopy 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
我有完全相同的但在 Windows 和 xampp 上。我的解决方案很简单:点击此链接:http://curl.haxx.se/ca/cacert.pem 复制整个页面并将其保存在:“cacert.pem”
然后在您的 php.ini 文件中插入或编辑以下行: curl.cainfo = "[pathtothisfile]\cacert.pem"
问题解决了
So from what I have understand thi file (https://curl.haxx.se/ca/cacert-2017-01-18.pem) is a bundle of CA certificates that you use to verify that the server is really the correct site you're talking to.
所以据我所知,这个文件(https://curl.haxx.se/ca/cacert-2017-01-18.pem)是一组 CA 证书,用于验证服务器是否是正确的站点你在和你说话。
So the fact that I have not setted this file into my Apache could be the cause of my problem?
所以我没有将此文件设置到我的 Apache 中的事实可能是我问题的原因?
If ys what have I to do exactly to set it? I have not undertand what have I to do with this downloaded file.
如果是,我该怎么做才能设置它?我不明白我与这个下载的文件有什么关系。
回答by
Solved by myself, this is THE problem explaination and solution ;-)
由我自己解决,这是问题的解释和解决方案;-)