WebClient.DownloadFile can't establish secure SSL/TLS channel

  • Thread starter Thread starter SimplicityFarSideOfComplexity
  • Start date Start date
S

SimplicityFarSideOfComplexity

Guest
I cannot download a publicly available file from a government webserver using .Net framework 4.8 or .Net core 3.1. I am able to download the file using Chrome, Firefox, or curl.

WebClient.DownloadFile() worked for over a year running as an Azure app service. It ran successfully Sept. 11, 2020 and hasn't worked since. It no longer works on my Windows 10 Pro computer. I also tried HttpWebRequest/HttpWebResponse without luck. I suspect server or firewall rule is blocking the request due to missing Http header? I tried setting user-agent header and forcing the protocol to TLS v1.2 and TLS v1.3. I also tried other ServicePointManager properties/overrides with no luck.

WireShark shows client Hello sends TLSv1.2 cipher list. I matched several of these ciphers to the server's list, using SSLLabs server report. Server supports TLS v1.2 and TLS v1.3. After Client Hello, Server responds with [ACK] and then [RST, ACK] and no Server Hello.

I'm to the point I may create a c++ cli program and link to libcurl and call it from c# - all just to download a publicly available file. See code for the url.

private void DownloadTest()
{
//ServicePointManager.Expect100Continue = true;
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
//ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };

try
{
using (var client = new WebClient())
{
client.DownloadFile("https://cops.fas.gsa.gov/awards/awards_2021.csv", @"c:\awards_2021.csv");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}







Continue reading...
 
Back
Top