我们已经开始使用 ASP.NET recaptcha 控件,它工作正常。但我们的要求之一是所有出站流量都通过 Https。
我知道recaptcha 支持https,但不清楚使用ASP.NET 插件选项时如何配置(或者即使它是可配置的)。
有没有人有这方面的经验?
我将扩展我到目前为止发现的内容......
Recaptcha 包包含 3 个公共类
RecaptchaControl,
RecaptchaValidator
和
RecaptchaResponse
RecaptchaControl
是一个 Asp.NET 控件,那里的 recaptcha 特定方法似乎与主题/外观有关。
Validator 的一个实例有一个 RemoteIP 字段(我认为它代表验证服务器),但我无法将它绑定到控件。
RecaptchaResponse
似乎或多或少代表了一个具有可能响应的枚举(有效/无效/连接失败)。
如果请求是 https ,Recaptcha 控件看起来会智能地选择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();
}