我们已经开始使用 ASP.NET recaptcha 控件,它工作正常。但我们的要求之一是所有出站流量都通过 Https。
我知道recaptcha 支持https,但不清楚使用ASP.NET 插件选项时如何配置(或者即使它是可配置的)。
有没有人有这方面的经验?
我将扩展我到目前为止发现的内容......
Recaptcha 包包含 3 个公共(public)类RecaptchaControl,
RecaptchaValidator
和RecaptchaResponse
RecaptchaControl
是一个 Asp.NET 控件,那里的 recaptcha 特定方法似乎与主题/外观有关。
Validator 的一个实例有一个 RemoteIP 字段(我认为它代表验证服务器),但我无法将它绑定(bind)到控件。RecaptchaResponse
似乎或多或少代表了一个具有可能响应的枚举(有效/无效/连接失败)。
貌似 Recaptcha 控件智能选择 https 如果请求是 https。
我假设它对验证做同样的事情,但从源代码中并不清楚
http://code.google.com/p/recaptcha/source/browse/trunk/recaptcha-plugins/dotnet/library/
private const string VerifyUrl = "http://www.google.com/recaptcha/api/verify";
private const string RECAPTCHA_SECURE_HOST = "https://api-secure.recaptcha.net";
private const string RECAPTCHA_HOST = "http://api.recaptcha.net";
--------------------------------SNIP------------------------------------
/// <summary>
/// This function generates challenge URL.
/// </summary>
private string GenerateChallengeUrl(bool noScript)
{
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.Append(Context.Request.IsSecureConnection || this.overrideSecureMode ? RECAPTCHA_SECURE_HOST : RECAPTCHA_HOST);
urlBuilder.Append(noScript ? "/noscript?" : "/challenge?");
urlBuilder.AppendFormat("k={0}", this.PublicKey);
if (this.recaptchaResponse != null && this.recaptchaResponse.ErrorCode != string.Empty)
{
urlBuilder.AppendFormat("&error={0}", this.recaptchaResponse.ErrorCode);
}
return urlBuilder.ToString();
}
最佳答案
如果您查看 http://recaptcha.net/apidocs/captcha/client.html它说:
"In order to avoid getting browser warnings, if you use reCAPTCHA on an SSL site, you should replace http://api.recaptcha.net with https://api-secure.recaptcha.net."
很明显,recaptcha 支持 HTTPS 提交。 ASP.NET 控件是否有任何可以配置出站 URL 的属性?在最坏的情况下,您可能需要使用 Reflector检查代码并查看它是如何构建的。
关于asp.net - .NET 验证码 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2636809/