Archive

Posts Tagged ‘SSL/TLS secure channel’

C# Error while calling API – Could not create SSL/TLS secure channel

Other day, we were getting following error while calling SSL enables 3rd party API from C# console.

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

Fix:

  • Add below statement before making your API call, which validates the SSL certification.

ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};

  • Include following namespaces

using System.Security.Cryptography.X509Certificates;
using System.Net.Security;

🙂

 

Advertisement
Categories: Misc Tags: , ,