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

J Reynolds 21 Reputation points
2020-10-07T02:02:24.313+00:00

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 as an Azure app service. It failed Sept. 14, 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've tried setting user-agent header and forcing the protocol along with 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. After Client Hello, Server responds with [ACK] and then [RST, ACK] and no Server Hello.

` 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());  
        }  
    }  

`

30460-wireshark-screen.gif

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,611 questions
0 comments No comments
{count} votes

Accepted answer
  1. Drake Wu - MSFT 991 Reputation points
    2020-10-07T06:19:25.907+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Currently, Microsoft Q&A supports the products listed over here: supported topics (more to be added later on).

    Your question about C# language is not supported yet now. The C# team is actively answering questions in the Visual C# Forum.

    Thank you.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.