I’m trying to call a webservice that sits on a domain protected by SSL but the SSL certificate doesn’t match the domain name, and therefore throws this error:

 The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

To fix this and ignore the error, you can add this line before you call the webservice:

System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s