gpt4 book ai didi

vb.net - ReCAPTCHA 关闭底层连接

转载 作者:行者123 更新时间:2023-12-01 12:16:07 26 4
gpt4 key购买 nike

在 VS2012 (VB.Net) 中运行我的 ReCAPTCHA 例程,我得到了错误

The underlying connection was closed. An unexpected error occurred on a receive



这段代码已经工作了几个星期,现在这周决定给我上面的错误。

有人可以告诉我问题是什么吗?谢谢!

这是我的代码:
        Dim recaptchaResponse As String = Request.Form("g-recaptcha-response")
If Not String.IsNullOrEmpty(recaptchaResponse) Then
Dim request As Net.WebRequest = Net.WebRequest.Create("https://www.google.com/recaptcha/api/siteverify?secret={MySecretKey}&response=" + recaptchaResponse)
request.Method = "POST"
request.ContentType = "application/json; charset=utf-8"
Dim postData As String = ""

'get a reference to the request-stream, and write the postData to it
Using s As IO.Stream = request.GetRequestStream()
Using sw As New IO.StreamWriter(s)
sw.Write(postData)
End Using
End Using

'**This next line of code triggers the error**
Using s As IO.Stream = request.GetResponse().GetResponseStream()
Using sr As New IO.StreamReader(s)
'decode jsonData with javascript serializer
Dim jsonData = sr.ReadToEnd()
If jsonData.IndexOf("{" & vbLf & " ""success"": true,") > -1 Then
Return True
Else
lblError.Text = jsonData
End If
End Using
End Using

最佳答案

内部异常是:

System.ComponentModel.Win32Exception (0x80004005): The client and server cannot communicate, because they do not possess a common algorithm at System.New.SSPIWrapper.AcquireCredentialsHandle

我发现网络管理员决定在不告诉我的情况下实现对 TLS 1.0 协议(protocol)的禁令。

此问题的解决方法是确保 ReCAPTCHA 通过 TLS 1.2 进行通信。这是通过在例程顶部的额外代码行完成的:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

关于vb.net - ReCAPTCHA 关闭底层连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48156519/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com