2

I am trying to access a web api using below C# code :

private static CertificateContext authenticationContext;
authenticationContext = new CertificateContext(new Uri(endpoint), ThumbPrint);
var client = authenticationContext.GetHttpClient();
var response = await client.GetStringAsync(url);

It was working fine initially but later i am getting below error:

The request was aborted: Could not create SSL/TLS secure channel.

I checked some forums and as per the suggestions i tried with below options, but nothing worked for me

    1.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
    2.ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, 
                SslPolicyErrors sslPolicyErrors) { return true; };

Kindly help me to fix this error. Thanks in advance

Manoj Nayak
  • 2,449
  • 9
  • 31
  • 53
  • 1
    https://stackoverflow.com/questions/41720564/the-request-was-aborted-could-not-create-ssl-tls-secure-channel-system-net-w[ Worked for me](http://) – NeoAsh Sep 20 '18 at 10:54

0 Answers0