c# - reCaptcha 和 SSL 网站

标签 c# asp.net-mvc ssl recaptcha

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

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

问候。

最佳答案

我认为您需要更改您使用的 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 库,我认为您的答案是升级您的版本。

关于c# - reCaptcha 和 SSL 网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5911227/

相关文章:

c# - 没有年份值的 Datetime.tryparse

c# - GoogleOAuth2AuthenticationOptions google+ API 关闭

java - 为 ssl 身份验证编写 java 客户端

java高级休息客户端连接给出ssl错误

c# - 生成 WPF 窗口的屏幕截图

c# - 在 web.config 中包含数据库密码的潜在安全风险是什么

javascript - 文化敏感的字符串排序

asp.net - MVC 4 中的级联下拉列表

javascript - 为什么 jquery ajax 调用 Controller 没有发现我的异常?

python - 在开发服务器(在本地主机上)上运行适用于 Google Cloud Endpoints 的 API Explorer 不再有效