我正在尝试调试应用而不将fiddler设置为其代理。
为此,我设置了基于fiddler.core的应用程序,该应用程序驻留在网络中的其他计算机上,并在hosts文件中添加了一个条目。
这是应用程序的代码:
private static Proxy googleEndpoint;
static void Main(string[] args)
{
List<Fiddler.Session> oAllSessions =new List<Session>();
Fiddler.FiddlerApplication.BeforeRequest += (i) => Console.WriteLine("Before request: "+i.fullUrl);
FiddlerApplication.AfterSessionComplete += (i) =>
{
Console.WriteLine("After request: "+i.fullUrl);
lock (oAllSessions)
{
oAllSessions.Add(i);
}
};
//https://www.google.com.ua/
googleEndpoint = FiddlerApplication.CreateProxyEndpoint(443, true, "www.google.com.ua");
if (null != googleEndpoint)
{
Console.WriteLine("google.com.ua endpoint mounted");
}
else
{
Console.WriteLine("failed to mount google.com.ua endpoint");
}
Console.ReadKey();
SaveSessionsToDesktop(oAllSessions);
}
private static void SaveSessionsToDesktop(List<Fiddler.Session> oAllSessions)
{
bool bSuccess = false;
string sFilename = DateTime.Now.ToString("hh-mm-ss") + ".saz";
try
{
try
{
Monitor.Enter(oAllSessions);
TranscoderTuple oExporter = FiddlerApplication.oTranscoders.GetExporter("SAZ");
if (null != oExporter)
{
Dictionary<string, object> dictOptions = new Dictionary<string, object>();
dictOptions.Add("Filename", sFilename);
// dictOptions.Add("Password", "pencil");
bSuccess = FiddlerApplication.DoExport("SAZ", oAllSessions.ToArray(), dictOptions, null);
}
else
{
Console.WriteLine("Save failed because the SAZ Format Exporter was not available.");
}
}
finally
{
Monitor.Exit(oAllSessions);
}
WriteCommandResponse(bSuccess ? ("Wrote: " + sFilename) : ("Failed to save: " + sFilename));
}
catch (Exception eX)
{
Console.WriteLine("Save failed: " + eX.Message);
}
}
public static void WriteCommandResponse(string s)
{
ConsoleColor oldColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(s);
Console.ForegroundColor = oldColor;
}
但是当我尝试从目标计算机访问https://www.google.com.ua
时,请求现在超时。
Fiddler应用显示已收到BeforeRequest
事件中的请求,但它从未发送回复(AfterSessionComplete
永远不会被调用)。
为什么会发生这种情况,我该如何解决?
如何为端口80执行相同的操作?
答案 0 :(得分:1)
我相信您要记住,除非您重新配置客户端以信任FiddlerServer的根证书,否则它不会向FiddlerCore发出HTTPS请求。它将在获得拦截证书后立即关闭连接。
如果附加BeforeResponse事件处理程序,您会看到什么?它会开火吗?