我们当前的流程运行良好,能够下载文件,直到该网站决定切换到TLS 1.2协议。现在,我们的文件下载不再有效。
我们现有的解决方案基于this vb.net solution,但这似乎无法处理TLS下载。我可以看到该文件,连接到它但无法下载它。有没有办法在VB.net或C#中处理这个?
答案 0 :(得分:0)
这对我有用:
Imports System.Net
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
Dim webclient As New WebClient
webclient.BaseAddress = Dts.Variables("ServerURL").Value
WebClient.Credentials = New NetworkCredential(Dts.Variables("ServerUsername").Value.ToString, Dts.Variables("ServerPassword").Value.ToString)
Dim filename As String = "C:\Temp\Sample.txt"
WebClient.DownloadFile(Dts.Variables("ServerURL").Value, filename)