How to redirect https tunnel traffic to https://localhost:8444 with FiddlerCore

239 Views Asked by At

How to redirect https tunnel traffic to https://localhost:8444 with FiddlerCore? The CONNECT has an upgrade to WebSocket and the HTTPS traffic is through WS messages.

The following code is from FiddlerScript and it works like a charm.

if(oSession.fullUrl.Contains("xxx") && oSession.HTTPMethodIs("GET"))
{
    oSession.host = "localhost:8444";
    oSession["x-overrideCertCN"] = "xxx-int.com";

}
if(oSession.fullUrl.Contains("xxx") && oSession.HTTPMethodIs("CONNECT"))
{
    oSession["x-replywithtunnel"] = "GenerateTunnel";
}

The following code is C# code from my program and it does not redirect to localhost :(

private static void FiddlerApplication_BeforeRequest(Session session)
    {
        if (session == null)
            return;           
        
        if (session.fullUrl.Contains("xxx-int.com"))
        {
            if (session.HTTPMethodIs("CONNECT"))
            {
                session.oFlags["x-replywithtunnel"] = "GenerateTunnel";
            }

            if (session.HTTPMethodIs("GET") && session.HostnameIs("xxx-int.com:443"))
            {
                session.host = "127.0.0.1:8444";
                session["x-overrideCertCN"] = "xxx-int.com";
            }
        }
    }

Other Relevant code pieces

Fiddler.CONFIG.IgnoreServerCertErrors = true;
Fiddler.CONFIG.sHostsThatBypassFiddler = ""https://*.resources.office.net";";
Fiddler.FiddlerApplication.Startup(8888, FiddlerCoreStartupFlags.Default);
FiddlerTaskLibrary.EnableHttpsCapture();

Please assist. I did look at similar questions but it seems I am not able to get the code trials working. Thanks

0

There are 0 best solutions below