reCaptcha 和 SSL 网站

发布于 2024-11-05 15:02:49 字数 1655 浏览 1 评论 0原文

我在 asp.net mvc 下的网页上使用 reCaptcha。这个网站有 SSL 认证,但我在使用 reCaptcha 时遇到了问题。 这是我在 View: 上的代码

<script type="text/javascript" src="https://api-secure.recaptcha.net/challenge?k=***Public key****"> </script>
<noscript>
<iframe src="https://api-secure.recaptcha.net/noscript?k=***Public key****" height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
</noscript>

,这个代码是我在 AccountController: 上的代码

private bool PerformRecaptcha()
{
    var validator = new RecaptchaValidator
    {
        PrivateKey = "**Private Key***", 
        RemoteIP = Request.UserHostAddress,
        Response = Request.Form["recaptcha_response_field"],
        Challenge = Request.Form["recaptcha_challenge_field"]

    };

    try
    {
        var validationResult = validator.Validate();

        if (validationResult.ErrorMessage == "incorrect-captcha-sol")
            ModelState.AddModelError("ReCaptcha", string.Format("Please retry the ReCaptcha portion again."));

        return validationResult.IsValid;
    }
    catch (Exception e)
    {
        ModelState.AddModelError("ReCaptcha", "an error occured with ReCaptcha please consult documentation.");
        return false;
    }
}

,我的库版本是 1.0.5.0。

当我加载注册表单时,Opera 上出现此警报:

规则服务器证书与服务器名称匹配。您想接受吗?

如果我接受此证书,则显示 reCaptcha 代码,但如果不接受,则不会查看 reCaptcha 代码。

你能帮我解决这个问题吗? 如果您需要有关我的代码的更多信息,请随时向我询问。

问候。

I using a reCaptcha on my web page under asp.net mvc. This web site have a SSL certificated, and I having and problem with reCaptcha.
This is my code on View:

<script type="text/javascript" src="https://api-secure.recaptcha.net/challenge?k=***Public key****"> </script>
<noscript>
<iframe src="https://api-secure.recaptcha.net/noscript?k=***Public key****" height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
</noscript>

and this code is that I have on AccountController:

private bool PerformRecaptcha()
{
    var validator = new RecaptchaValidator
    {
        PrivateKey = "**Private Key***", 
        RemoteIP = Request.UserHostAddress,
        Response = Request.Form["recaptcha_response_field"],
        Challenge = Request.Form["recaptcha_challenge_field"]

    };

    try
    {
        var validationResult = validator.Validate();

        if (validationResult.ErrorMessage == "incorrect-captcha-sol")
            ModelState.AddModelError("ReCaptcha", string.Format("Please retry the ReCaptcha portion again."));

        return validationResult.IsValid;
    }
    catch (Exception e)
    {
        ModelState.AddModelError("ReCaptcha", "an error occured with ReCaptcha please consult documentation.");
        return false;
    }
}

and my library version is 1.0.5.0.

When I load the register form I have this alert on Opera:

The rules server certificate matches the server name. Do you want to accept?

If I accept this certificate, displays reCaptcha code, but if not, I don't view reCaptcha Code.

Can you help me with this?
If you need more information about my code, feel free to ask to me.

Regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一桥轻雨一伞开 2024-11-12 15:02:50

加强 JasonStoltz 的回答:

  • 您已经在使用最新的 DLL 版本,无需更新此
  • 您可以/应该在视图中使用 RecaptchaControlMvc.GenerateCaptcha() 方法,而不是编写自己的方法(它将使用新的 URL)

Sharpening up on JasonStoltz's answer:

  • You are already using the latest DLL version, there's no need to update this
  • You can/should use RecaptchaControlMvc.GenerateCaptcha() method in your View instead of writing your own (it will use the new URL)
早乙女 2024-11-12 15:02:49

我认为您需要更改正在使用的网址以包含验证码。四月份很多人都遇到了同样的问题。 Recaptcha 让“api-secure.recaptcha.net”的证书过期 ”。如果您将其更改为使用“https://www.google.com/recaptcha/api/ XXX”网址而不是“https://api-secure.recaptcha.net/XXX< /a>”,它绝对应该解决你的问题。

看起来这个问题实际上已经被回答过:recaptcha https问题在 https://api-secure.recaptcha.net/ 上。由于您正在使用 .NET 库,我认为您的答案是升级您的版本。

I think you need to change the url you are using to include recaptcha. A number of people had the same problem in April. Recaptcha let the certificate expire for "api-secure.recaptcha.net". If you change it to use the "https://www.google.com/recaptcha/api/XXX" url instead of "https://api-secure.recaptcha.net/XXX", it should definitely fix your issue.

It looks like this one has actually been answered before: recaptcha https problem on https://api-secure.recaptcha.net/. Since you are using the .NET library, I think your answer is to upgrade your version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文