Reputation: 715
I have written a C# client to make a multipart-form data post to a server on the internet. While testing my code, I started getting exceptions as follows:
{System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
I tried accessing the web resource using my browser and realized that there is an issue with the SSL certificate of the website. The website is owned by a third part and I don't know when they will fix this problem.
Is there any way I can ignore this security exception and make some change in my code so that it keeps working?
I am using the HttpWebRequest class to perform http posts.
Upvotes: 3
Views: 2313
Reputation: 1064244
At the crudest level:
ServicePointManager.ServerCertificateValidationCallback = delegate
{ return true; }; // WARNING: accepts all SSL certificates
You should probably be a bit more granular though, looking at the certificate/chain a bit.
Upvotes: 6