我正在使用.net中的webclient类,我去了一个网站。
Dim oWebClient As New WebClient()
Dim oDownloadedPage As String = oWebClient.DownloadString(<site>)
经过一番搜索后发现我尝试下载的网站必须禁用TLS1.0
所以我将ServicePointManger更改为此
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 Or
SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
我得到了同样的错误..所以我决定把它改成这个..
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 Or
SecurityProtocolType.Tls Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
看看我在那里做了什么?我切换了订单,然后它工作了。
有人可以向我解释一下订购的不同之处是什么?为什么这很重要?我想知道我是否会去下载一个TLS 1.0网站,如果它会失败。
答案 0 :(得分:0)
System.Net.ServicePointManager.SecurityProtocol = DirectCast(3072, System.Net.SecurityProtocolType) 'TLS 1.2
Dim inStream As StreamReader
Dim webRequest As WebRequest
Dim webresponse As WebResponse
Dim cResult As String = ""
dim cURL as String="https://your.page.com"
webRequest = WebRequest.Create(cURL)
webresponse = webRequest.GetResponse()
inStream = New StreamReader(webresponse.GetResponseStream())
cResult = inStream.ReadToEnd()
这对我有效!