0

Under the Batch Service option, we are running a custom dot net activity, and that .net tool downloads data from some APIs. It was working fine without any issues until yesterday. Now we are facing the below error while downloading data from the APIs. I don't know why we are facing such an issue suddenly.

Error: The request was aborted: Could not create SSL/TLS secure channel. StackTrace: at System.Net.WebClient.OpenRead(Uri address) at Import.DownloadSite(String url, String type)

The same .Net tool works fine in our local desktop machines(Windows 10 OS). Getting the error only in the batch account machine. So I think the problem is in the batch account machine.

Using the below C# code for downloading data from the APIs:

WebClient wc = new WebClient();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
return wc.DownloadString(string.Format(ApiUrl, type));

I tried most of the solutions suggested in the below link, and nothing works for me. The request was aborted: Could not create SSL/TLS secure channel

More information:

  • .NET Framework: v4.5
  • Batch machine: Windows Server 2012 R2 (x64)
Kathir Subramaniam
  • 1,014
  • 1
  • 12
  • 24

1 Answers1

0

You need to Add HTTP Header "Expect" with value "100-continue". In your case, please add these lines of code before creating the request :

 ServicePointManager.Expect100Continue = true;
 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
        | SecurityProtocolType.Tls11
        | SecurityProtocolType.Tls12
        | SecurityProtocolType.Ssl3;