[SOLVED] C# & HttpClient for SSL/TLS: Error The request was aborted: The request was canceled.

Sometimes our software that bases on HttpClient class requests has problem with connecting to services (AZURE or other portals) or REST API functions┬áto https addresses (SSL). We’ve got error: “Error The request was aborted: The request was canceled.” and our connection is rejected at once.

That can means that we should verify settings for TLS type of protocol, that is setting by default. In 99% that means that we should use below instruction:

System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

like on attached screen:

In my practical programming in numerous projects this line eliminated a lot of problems in case of mentioned error

March 31st, 2020