c#FiddlerCore AutoResponder隧道连接失败
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c#FiddlerCore AutoResponder隧道连接失败相关的知识,希望对你有一定的参考价值。
所以我试图获得与Fiddler应用程序内的“AutoResponder”基本相同的功能。
我也需要这个离线工作。
网站我试图自动响应它HTTP(S)我输入代码,要求用户信任我已包含在下面的根证书,以使其在某种程度上相关。
if (Fiddler.CertMaker.rootCertExists())
{
if (!Fiddler.CertMaker.rootCertIsTrusted())
{
MessageBox.Show(this, "You need to approve the Fiddler Root CA.", "First Time?");
Fiddler.CertMaker.trustRootCert();
}
}
else
{
Fiddler.CertMaker.createRootCert();
if (!Fiddler.CertMaker.rootCertIsTrusted())
{
MessageBox.Show(this, "You need to approve the Fiddler Root CA.", "First Time?");
Fiddler.CertMaker.trustRootCert();
}
}
if (!Fiddler.CertMaker.rootCertIsTrusted())
{
MessageBox.Show(this, "Fiddler Root CA not Trusted.", "Error");
this.Close();
}
至于自动回复器(我非常肯定会导致问题)
FiddlerApplication.Startup(8080, true, true, true);
FiddlerApplication.BeforeRequest += delegate (Session session)
{
if (session.HTTPMethodIs("CONNECT")) { session.oFlags["X-ReplyWithTunnel"] = "Fake for HTTPS Tunnel"; return; }
if (session.uriContains("https://google.com"))
{
session.bBufferResponse = true;
}
};
FiddlerApplication.BeforeResponse += delegate (Session session)
{
session.utilDecodeResponse();
session.LoadResponseFromFile("Google.txt");
};
但是在运行此代码后,我无法访问任何HTTPS网站,即使在尝试AutoRespond的网站上也会收到错误“ERR_TUNNEL_CONNECTION_FAILED”。
答案
我设法修复它
Fiddler.FiddlerApplication.BeforeRequest += new SessionStateHandler(FiddlerApplication_BeforeRequest);
FiddlerApplication.Startup(8080 , true,true);
-
private void FiddlerApplication_BeforeRequest(Session oSession)
{
FiddlerApplication.BeforeRequest += delegate (Session session)
{
Fiddler.FiddlerApplication.BeforeRequest += delegate (Fiddler.Session oS)
{
if (!oS.uriContains("google.com") && oSession.HTTPMethodIs("CONNECT")) { oSession.oFlags["X-ReplyWithTunnel"] = "Connect for real.."; }
if (oS.uriContains("google.com") && oS.HTTPMethodIs("CONNECT")) { oS["x-replywithtunnel"] = "Fake tunnel..."; }
if (oS.uriContains("https://google.com/"))
{
oS.oFlags["x-replywithfile"] = AppDomain.CurrentDomain.BaseDirectory + "google.txt";
}
}
};
};
以上是关于c#FiddlerCore AutoResponder隧道连接失败的主要内容,如果未能解决你的问题,请参考以下文章