2016-10-13 2 views
1

그래서 ReCaptcha가 ColdFusion (전체 소스 코드)에서 작동하도록 노력하고 있습니다. 나는 get/post를 사용하여 시도했는데 같은 에러가 난다. Recaptcha 오류 : I/O 예외 : 인증서의 이름이 호스트 이름과 일치하지 않습니다.

CFHTTP Error

I/O Exception: Name in certificate `google.com' does not match host name `www.google.com' 

나는 PHP (아래 전체 소스 코드)에 내 코드를 변환하고 그것을 잘 작동합니다. 유일한 차이점은 PHP 코드는 get 메소드 만 사용한다는 것입니다.

내가 잘못하고있는 아이디어가 있습니까? 도와 주셔서 감사합니다.

의 ColdFusion 코드 :

<cfif StructKeyExists(Form, "submit")> 
    <cfset googleurl = "https://www.google.com/recaptcha/api/siteverify" /> 
    <cfset recaptchasecret = "secret-key-here" /> 
    <cfset recaptcha = FORM["g-recaptcha-response"] > 
    <cfset remoteip = CGI["remote_addr"] /> 

    <!---post method---> 
    <!---<cfhttp url="#googleurl#" method="post" resolveURL="yes"> 
     <cfhttpparam type="formfield" name="secret" value="#recaptchasecret#" /> 
     <cfhttpparam type="formfield" name="response" value="#recaptcha]#" /> 
     <cfhttpparam type="formfield" name="remoteip" value="#remoteip#" /> 
    </cfhttp>---> 

    <!---get method---> 
    <cfhttp url="#googleurl#?secret=#recaptchasecret#&response=#recaptcha#&remoteip=#remoteip#" method=get/> 

    <cfdump var="#cfhttp#"><hr> 
    <cfabort> 
</cfif> 

<html> 
    <head> 
     <title>Google recapcha demo - Codeforgeek</title> 
     <script src='https://www.google.com/recaptcha/api.js'></script> 
    </head> 
    <body> 
     <h1>Google reCAPTHA Demo</h1> 
     <form id="comment_form" action="test.cfm" method="post"> 
      <input type="email" placeholder="Type your email" size="40"><br><br> 
      <textarea name="comment" rows="8" cols="39"></textarea><br><br> 
      <input type="submit" name="submit" value="Post comment"><br><br> 
      <div class="g-recaptcha" data-sitekey="site-key-here"></div> 
     </form> 
    </body> 
</html> 

PHP 코드 :

<?php 
    if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
     var_dump($_POST); 

     $googleurl = "https://www.google.com/recaptcha/api/siteverify"; 
     $secretKey = "secret-key-here"; 
     $captcha=$_POST['g-recaptcha-response']; 
     $ip = $_SERVER['REMOTE_ADDR']; 

     $response=file_get_contents($googleurl."?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip); 

     $responseKeys = json_decode($response,true); 

     var_dump($responseKeys); 
    } 
?> 

<html> 
    <head> 
     <title>Google recapcha demo - Codeforgeek</title> 
     <script src='https://www.google.com/recaptcha/api.js'></script> 
    </head> 
    <body> 
     <h1>Google reCAPTHA Demo</h1> 
     <form id="comment_form" action="test.php" method="post"> 
      <input type="email" placeholder="Type your email" size="40"><br><br> 
      <textarea name="comment" rows="8" cols="39"></textarea><br><br> 
      <input type="submit" name="submit" value="Post comment"><br><br> 
      <div class="g-recaptcha" data-sitekey="site-key-here"></div> 
     </form> 
    </body> 
</html> 

답변

0

그것은 SSL 문제가 있어요 - 자바가 "www.google.com"제대로 연결할 수 없습니다. 임시 해결 방법으로 <cfset googleurl = "https://google.com/recaptcha/api/siteverify" />을 사용하십시오. 하지만 확실히 자바의 인증서 저장소를 업데이 트하십시오.

+0

반드시 ssl url과 POST를 사용해야합니다. 비밀 열쇠를 노출하고있는 그대로입니다. – Jules