【问题标题】:reCaptcha and SSL web sitereCaptcha 和 SSL 网站
【发布时间】:2011-05-06 12:12:34
【问题描述】:

我在 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 代码。

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

问候。

【问题讨论】:

  • 那是 Google 的 ASP.NET reCaptcha 控件吗?这只是 Opera 中的一个问题吗?
  • 不,它发生在所有网络浏览器上。

标签: c# asp.net-mvc ssl recaptcha


【解决方案1】:

我认为您需要更改正在使用的 url 以包含 recaptcha。许多人在四月份遇到了同样的问题。 Recaptcha let the certificate 为“api-secure.recaptcha.net”过期。如果您将其更改为使用“https://www.google.com/recaptcha/api/XXX”网址而不是“https://api-secure.recaptcha.net/XXX”,它肯定会解决您的问题。

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

【讨论】:

  • 实际上,他并没有使用 .NET 库来处理需要更改的 View 部分。
  • 直到星期一我才能测试这个解决方案,但我认为这将是解决方案。感谢您的回答!
【解决方案2】:

进一步了解 JasonStoltz 的回答:

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

【讨论】:

  • 阿德里安,谢谢你的回答,周一我尝试了两种解决方案。
猜你喜欢
  • 1970-01-01
  • 2023-04-08
  • 2020-09-16
  • 1970-01-01
  • 2019-07-28
  • 1970-01-01
  • 1970-01-01
  • 2022-08-05
  • 2015-08-19
相关资源
最近更新 更多