2015-06-08 153 views
0

我想要使用验证码2.0版,使用PHP,在服务器验证我用这个代码:谷歌验证码用PHP验证

if(isset($_POST['Direccion_Email']) AND ($_POST['enviar'])) { 
    if(isset($_POST['g-recaptcha-response'])){ 
    $mensaje_error = ""; 
    include 'config-formulario.php'; 
    require_once __DIR__ . '/recaptcha-master/src/autoload.php'; 
    $recaptcha = new \ReCaptcha\ReCaptcha($secret); 
    $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); 
if (!$resp->isSuccess()) { 
     $mensaje_error .= "Control Anti SPAM no es válido <br />"; 
     $errors = $resp->getErrorCodes(); 
    } else { 
     //DO SOMETHING; 
    } 

但是,当我试图发送一个简单的与我联系名字形成,电子邮件和评论,它返回此警告:

警告:file_get_contents():SSL操作失败,代码为1. OpenSSL错误消息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败/ home/diego/www /systec/scripts/recaptcha-master/src/ReCaptcha/RequestMethod/Post.php上线68

警告:file_get_contents()函数:无法上线使能加密在/home/diego/www/systec/scripts/recaptcha-master/src/ReCaptcha/RequestMethod/Post.php 68

警告:的file_get_contents(https://www.google.com/recaptcha/api/siteverify) :无法打开流:操作失败/ 68/012///systec/script/recaptcha-master/src /ReCaptcha/RequestMethod/Post.php 68行

我在localhost上测试这个。

有任何建议。

谢谢。

+0

这些错误可能会去方式共享主机 - 也许不是添加在SSL证书捆绑你的代码库 –

+1

所以我不能测试我的本地服务器上的应用程序更容易? – diego

+0

可以..如果你真的想 –

回答

0

从@jww作品答案形成了我:

对于步骤(1),见How do you sign Certificate Signing Request with your Certification Authority?。 (2),请参阅How to create a self-signed certificate with openssl?。后者还向您显示如何创建签名请求(而不是自签名证书)。它们是相同的步骤 - 唯一不同的是缺少用于签名请求的-x509选项。

+0

它在我的服务器上工作,但不在本地主机上。为什么? – Pathros

+1

它给你一个错误?如果是,你可以发布错误? – diego

+0

错误是:'file_get_contents():SSL操作失败,代码为1. OpenSSL错误消息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败,并位于同一行(68)。现在唯一的解决方案是删除cookie。 – Pathros