Could not establish trust relationship for SSL/TLS secure channel


no comments

Working with WebClient to fetch some data from a web service (HTTPS) return an error, now it’s fully understandable why this exception raised – the server certificate has expired and isn’t valid any more.

But how I can still getting the data from the service although the certificate isn’t valid???


You just need to override the ServerCertificateValidationCallback property – Gets or sets the callback to validate a server certificate.

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

And you’re done!

Add comment
facebook linkedin twitter email

Leave a Reply