0

I have added following line of code to Application_Start(), hoping that it could resolve the error Could not create SSL/TLS secure channel. But this still doesn't fix my issue.

ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

// stacktrace
System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)

Oddly, there isn't any problem if I initiate my requests over Https with Postman. I get 200 and API call works fine there.

Am I still missing something here? Or is there anything else I can perhaps try?

halfer
  • 19,824
  • 17
  • 99
  • 186
woodykiddy
  • 6,074
  • 16
  • 59
  • 100
  • Check answers [here](https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel) it may help. – ElasticCode Jun 22 '18 at 04:45
  • @WaelAbbas Already tried those suggestions but didn't work for me. – woodykiddy Jun 22 '18 at 05:02
  • Make sure SSL/TLS setting are checked from > Internet Explorer >Tools > Internet Options > Advanced tab > Scroll down to Security category, manually check the option box for Use TLS 1.1 and Use TLS 1.2 and Use SSL 3.0 – ElasticCode Jun 22 '18 at 05:10
  • @WaelAbbas yes these options are all ticked. I am not sure if it might be the issue on the server side though. – woodykiddy Jun 22 '18 at 05:18
  • which .Net version you are using? and what it the TLS version of the certificate? – ElasticCode Jun 22 '18 at 05:27
  • @WaelAbbas I am using .net 4.5, but not too sure of the TLS version of the certificate as it's already expired. – woodykiddy Jun 22 '18 at 06:25
  • Check [this answer](https://stackoverflow.com/a/703285/3134112) also they mention certificate need to be valid, and make sure you added this line `ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;` at the begining of `Application_Start()` – ElasticCode Jun 22 '18 at 06:33
  • @WaelAbbas yeah tried it as well. Still the same error. Does the cert have to be valid, not expired? – woodykiddy Jun 22 '18 at 06:57

0 Answers0