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;
🙂
Categories: Misc
API, C#, SSL/TLS secure channel
Comments (0)
Trackbacks (0)
Leave a comment
Trackback