C
C#•4mo ago
reeeeeee

ReCaptcha verify - The response ended prematurely

I an getting this error, when sending captchaData to the server for verifying. I would think the problem would be with accessing internet connection, but as far as I can see, the recaptcha verifying site can be accessed from the server. (https://www.google.com/recaptcha/api/siteverify) Any idea what else can i check?
13 Replies
canton7
canton7•4mo ago
Make sure that you're sending the full response? It's hard to be more specific with so little detail
reeeeeee
reeeeeee•4mo ago
Yeah ik, but I dont know what else could I say more... I am using var isCaptchaValid = await _recaptchaService.VerifyAsync(model.CaptchaResponse); and it throws and exception
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The response ended prematurely.
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The response ended prematurely.
It works locally and on first server, but not on the second server. (I am using correct Captcha keys for specific domain)
canton7
canton7•4mo ago
Oh, it's a HttpClient error. That wasn't clear -- it sounded like an error from recaptcha Look at the InnerException(s)
reeeeeee
reeeeeee•4mo ago
ah yes, sorry... i am only getting this:
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The response ended prematurely.
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The response ended prematurely.
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
in debug, the application is sending reques to this site:
System.Net.Http.HttpClient.IReCaptchaService.LogicalHandler: Information: Start processing HTTP request POST https://www.google.com/recaptcha/api/siteverify
System.Net.Http.HttpClient.IReCaptchaService.ClientHandler: Information: Sending HTTP request POST https://www.google.com/recaptcha/api/siteverify
System.Net.Http.HttpClient.IReCaptchaService.LogicalHandler: Information: Start processing HTTP request POST https://www.google.com/recaptcha/api/siteverify
System.Net.Http.HttpClient.IReCaptchaService.ClientHandler: Information: Sending HTTP request POST https://www.google.com/recaptcha/api/siteverify
which can be opened in chrome for example, so idk why would it fail when calling from the API
canton7
canton7•4mo ago
Can you debug it, break when the exception is thrown and inspect the exception?
reeeeeee
reeeeeee•4mo ago
sadly not.. i can access this server only from RDP inside RDP... I dont know how can i duplicate the issue
reeeeeee
reeeeeee•4mo ago
I have some additional info.. 🙂 I can open that link in browser, but can't curl it from cmd. I assume its something with firewall or something like that?
No description
canton7
canton7•4mo ago
That's schannel, the windows certificate store stuff Check your event log maybe, see if it logged a more specific error
reeeeeee
reeeeeee•4mo ago
ah yes i see. This is the error:
The certificate received from the remote server was issued by an untrusted certificate authority. Because of this, none of the data contained in the certificate can be validated. The TLS connection request has failed. The attached data contains the server certificate.
The SSPI client process is Ssms (PID: 10876).
The certificate received from the remote server was issued by an untrusted certificate authority. Because of this, none of the data contained in the certificate can be validated. The TLS connection request has failed. The attached data contains the server certificate.
The SSPI client process is Ssms (PID: 10876).
canton7
canton7•4mo ago
(Trustworthiness there is being determined by the Windows cert store stuff of course: nothing to do with .NET)
reeeeeee
reeeeeee•4mo ago
aha okay. I assume this should be done by sysadmin, or could I do that without any particular permissions?
canton7
canton7•4mo ago
No idea I'm afraid -- I haven't seen that specific error before
reeeeeee
reeeeeee•4mo ago
okay. Thank you for your help!