gpt4 book ai didi

vb.net - 使用 VB.NET 检索 API JSON (https)(错误 : Canceled the request: Unable to create a secure SSL/TLS channel)

转载 作者:太空宇宙 更新时间:2023-11-03 14:30:08 25 4
gpt4 key购买 nike

我正在尝试从我的 vb.net 代码查询 API,但在执行“GetResponse”时出现错误“取消请求:无法创建安全的 SSL/TLS channel

我已经修改了代码的很多东西试图解决我的问题但是没有任何效果......

我附上代码,我必须看看是否有人可以修复它

    Dim request As HttpWebRequest = HttpWebRequest.Create("https://api.flightstats.com/flex/schedules/rest/v1/json/flight/AA/1917/departing/2018/11/19?appId=583f892b&appKey=e960901ec7dcb40321306743b7a364d0")
request.Proxy = Nothing
request.UserAgent = "Test"

ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications

Dim response As HttpWebResponse = request.GetResponse
Dim response_stream As System.IO.Stream = response.GetResponseStream

Dim stream_reader As New System.IO.StreamReader(response_stream)
Dim Data As String = stream_reader.ReadToEnd
stream_reader.Close()

MsgBox(Data)

_

Public Function AcceptAllCertifications(ByVal sender As Object, ByVal certification As System.Security.Cryptography.X509Certificates.X509Certificate, ByVal chain As System.Security.Cryptography.X509Certificates.X509Chain, ByVal sslPolicyErrors As System.Net.Security.SslPolicyErrors) As Boolean
Return True
End Function

代码中有我要查询的api地址

最佳答案

在您的请求之前添加:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

关于vb.net - 使用 VB.NET 检索 API JSON (https)(错误 : Canceled the request: Unable to create a secure SSL/TLS channel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53393056/

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