tags:

views:

444

answers:

1

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.

+5  A: 

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.

Marc Gravell
Yup, I've used this one a few times. If you use task lists, make sure to put in a TODO or HACK in your comment. Or add warning to your list of keywords.
maxwellb