Disabling Certificate Validation in .Net

Hackered
Wednesday, March 5, 2014
by Sean McAlinden

So this post is more to act as a reminder for me... Sometimes when using self signed certificates you get the following error:   The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.  This is simply because the certificate is not trusted. Now there are multiple ways of avoiding this error, get a proper certificate, get the server to trust the self signed cert or hack in a bit of code that makes the problem just go away...

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

Nice...   Just make sure it doesn't end up in production.