This is a migrated thread and some comments may be shown as answers.

redirection to localhost not working in 2.3.8.5 but working in 4.6.2

1 Answer 116 Views
FiddlerCore
This is a migrated thread and some comments may be shown as answers.
amar
Top achievements
Rank 1
amar asked on 14 Aug 2020, 07:39 PM

Hi,

I have some redirection code in my test automation that does not work when FiddlerCore 2.3.8.5 is referenced.

When I update to 4.6.2 (through Install-Package into my .csproj) the redirection starts to work.

Questions

1) Did something change between 2.3.8.5 to 4.6.2 to affect WS traffic to localhost?

2) Is there a better way to code this and make it work with 2.3.8.5?

 

 

 

I have a question in stackoverflow, fyi..

https://stackoverflow.com/questions/63073681/how-to-redirect-https-tunnel-traffic-to-https-localhost8444-with-fiddlercore

 

Basically, my need is:

 

Redirect https tunnel traffic to https://localhost:8444 from my prod endpoint.The CONNECT has an upgrade to WebSocket and the HTTPS traffic is through WS messages.

My automation code:

        /// <summary>
        /// Thread function to start fiddlercore and initialize event handlers
        /// </summary>        
        private static void FiddlerMocking()
        {
            try
            {
                // Set up FiddlerCore and its handlers
                // Hook up our callbacks
                Fiddler.FiddlerApplication.BeforeRequest += delegate (Session session)
                {
                    Console.WriteLine("BEGIN-" + session.fullUrl);
                    
                    if (session.fullUrl.Contains("XXX-int.YYY.com"))
                    {
                        if (session.HTTPMethodIs("CONNECT"))
                        {
                            log.Comment("CONNECT---" + session.host.ToString());
                            session.oFlags["x-replywithtunnel"] = "GenerateTunnel";
                            return;
                        }
                        else if (session.HTTPMethodIs("GET"))
                        {
                            log.Comment("GETBEFORE---" + session.host.ToString());
                            session.host = "127.0.0.1:8444";
                            log.Comment("GETAFTER---" + session.host.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("IGNORING-" + session.fullUrl);
                        // following will not work in 2.3.8.5 but will work in 4.6.2
                        //session.Ignore(); 
                    }

                };
                
                Fiddler.FiddlerApplication.OnValidateServerCertificate +=

                                    new   System.EventHandler<ValidateServerCertificateEventArgs>(CheckCert);
                Fiddler.CONFIG.IgnoreServerCertErrors = true;

                // This is to bypass traffic related to iframe
                Fiddler.CONFIG.sHostsThatBypassFiddler = "https://*.resources.office.net";

                var rand = new Random();

                Fiddler.FiddlerApplication.Startup(rand.Next(9100, 9900),
                    FiddlerCoreStartupFlags.DecryptSSL |
                    FiddlerCoreStartupFlags.MonitorAllConnections |
                    FiddlerCoreStartupFlags.RegisterAsSystemProxy |
                    FiddlerCoreStartupFlags.CaptureLocalhostTraffic);

                // Enable HTTPS capture and add session handlers
                FiddlerTaskLibrary.EnableHttpsCapture();
                
            }
            catch
            {
                throw;
            }
        }

 

Please help.

Thanks,

Amrendra

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 19 Aug 2020, 08:42 AM

Hi Amrendra,

Version 2.3.8.5 was released in 2012 and yes, numerous things have changed between those two versions including improvements in the WebSocket support (take a look at the change log: https://www.telerik.com/support/whats-new/fiddler/release-history/fiddler-v2.x). My recommendation would be to upgrade to a newer version of FiddlerCore, ideally the latest 5.0 to take advantage of the most recent additions, especially since you already have the scenario you want to achieve running in a recent version.

Regards,
Petya
Progress Telerik

Tags
FiddlerCore
Asked by
amar
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or