Welcome to MSDN Blogs Sign in | Join | Help
How to debug C# WebHttpRequest HTTPS through Fiddler

Hi,

I was working on this project where I needed to get some HTTP requests intercepted by Fiddler. Everything worked nice and dandy until some of the requests needed to be done over HTTPS. Fiddler knows to decrypt those by having a fake SSL cert.

Unfortunately my code didn't like that too much so it started etting me this nice error:

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

Solution... you just need to disable the ServerCertificateValidationCallback

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(
                delegate
                {
                   return true;
                } );

That's all. Now you're requests can go through  Fiddler and you can debug them.

Thanks,
Ionutz

Posted: Tuesday, May 12, 2009 5:53 PM by ionutg

Comments

Eric Lawrence [MSFT] said:

Don't ship like that!  :-)

Alternative fix is to trust the Fiddler root certificate on your test machine while testing: see http://www.fiddler2.com/fiddler/help/httpsdecryption.asp

# October 28, 2009 7:38 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker