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