Sunday, July 12, 2009

Overriding ServerCertificateValidation

I found the following code very useful, when trying to debug https calls through fiddler. During this proxying, fiddler creates its own certificates, which will be failed by the programs. In order to override the behavior, while doing debugging, the following code could be used.


//using System.Net;
//using System.Security.Cryptography.X509Certificates;
//using System.Net.Security;

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

No comments:

Post a Comment