在VS2012 (VB.Net)中运行我的VS2012例程,我会得到错误
底层连接已关闭。接收时发生意外错误
这段代码已经运行了几个星期,现在这个星期已经决定给出上面的错误。
有人能告诉我问题出在哪里吗?谢谢!
这是我的代码:
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发布于 2018-01-08 23:46:18
内部例外是:
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协议的禁令。
解决此问题的方法是确保ReCAPTCHA通过TLS1.2进行通信。这是通过在例程顶部增加一行代码来完成的:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12https://stackoverflow.com/questions/48156519
复制相似问题