0

Our current process was working fine and was able to download files until the site decided to switch to TLS 1.2 protocol. Now, our file downloads no longer work.

Our existing solution is based on this vb.net solution and this does not seem to handle TLS downloads. I can see the file, connect to it but cant download it. Is there a way to handle this in either VB.net or C#?

rvphx
  • 2,324
  • 6
  • 40
  • 69
  • Do a google search for : codeproject tls c# – jdweng Jun 23 '17 at 16:23
  • Can you post the code you're working with and tell us the line it fails? As I see you have the link, the link may not always be there or be as specific as your own code. – Jimmy Smith Jun 23 '17 at 16:54
  • The code on the link is what I have on the package. The person who designed the package (long ago) copy pasted the code and changed the basic parameters such as URL and file name. The code fails on the connection.DownloadFile(filename, True) line. – rvphx Jun 23 '17 at 17:51

1 Answers1

0

This worked for me:

    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)