In Presentation/Nop.Web.Framework/Security/Captcha/GReCaptchaValidator.cs line 53:
/// <summary>
/// Validate
/// </summary>
/// <returns></returns>
public GReCaptchaResponse Validate()
{
GReCaptchaResponse result = null;
var httpClient = new HttpClient();
var requestUri = string.Empty;
requestUri = string.Format(RECAPTCHA_VERIFY_URL, SecretKey, Response, RemoteIp);
try
{
var taskResult = httpClient.GetAsync(requestUri);
taskResult.Wait();
var response = taskResult.Result;
response.EnsureSuccessStatusCode();
var taskString = response.Content.ReadAsStringAsync();
taskString.Wait();
result = ParseResponseResult(taskString.Result);
}
catch
{
result = new GReCaptchaResponse { IsValid = false };
result.ErrorCodes.Add("Unknown error");
}
finally
{
httpClient.Dispose();
}
return result;
}
This code does not work when nopCommerce is behind a proxy.
I had to add a WebProxy with the proxy address and a HttpClientHandler which is passed to the HttpClient.
It would be nice if you could add a setting in the administration area to configure a proxy.
Then the code above should have a if proxy is enabled condition.
Here is my code if it may help you. I may have set too many parameters but it currently works well so I won't touch it.
var webProxy = new WebProxy("proxy address")
{
BypassProxyOnLocal = true,
Credentials = CredentialCache.DefaultCredentials,
UseDefaultCredentials = true,
};
var handler = new HttpClientHandler()
{
UseDefaultCredentials = true,
Proxy = webProxy,
PreAuthenticate = true,
};
var httpClient = new HttpClient(handler);