1

Right I have the following code:

public partial class Form1 : Form
{
    delegate void UpdateUI();
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

        if (!Fiddler.CertMaker.rootCertExists())
        {
            if (!Fiddler.CertMaker.createRootCert())
            {
                throw new Exception("Unable to create cert for FiddlerCore.");
            }
        }

        if (!Fiddler.CertMaker.rootCertIsTrusted())
        {
            if (!Fiddler.CertMaker.trustRootCert())
            {
                throw new Exception("Unable to install FiddlerCore's cert.");
            }
        }
        Fiddler.FiddlerApplication.OnNotification += delegate (object snder, NotificationEventArgs oNEA) { MessageBox.Show("** NotifyUser: " + oNEA.NotifyString); };
        Fiddler.FiddlerApplication.Log.OnLogString += delegate (object snder, LogEventArgs oLEA) { MessageBox.Show("** LogString: " + oLEA.LogString); };
        Fiddler.FiddlerApplication.AfterSessionComplete += FiddlerApplication_OnAfterSessionComplete;
        Fiddler.FiddlerApplication.Startup(0, FiddlerCoreStartupFlags.Default & FiddlerCoreStartupFlags.DecryptSSL);

    }


    void FiddlerApplication_OnAfterSessionComplete(Session oSession)
    {
        if(oSession.fullUrl.Contains("google.com"))
        richTextBox1.Invoke(new UpdateUI(() =>
        {
            richTextBox1.AppendText(oSession.GetResponseBodyAsString());

        }));

    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        Fiddler.FiddlerApplication.Shutdown();
    }
}

The thing is with DecryptSSL flag set on startup the on aftersesssion complete never fires, I also never get any messages from either the notification or logs callbacks.

Any ideas?

Mrk Fldig
  • 3,550
  • 5
  • 25
  • 54

1 Answers1

0

I think port 0 might be a problem in the Startup(), I tried with port 8888:

Fiddler.FiddlerApplication.Startup(8888, FiddlerCoreStartupFlags.Default & FiddlerCoreStartupFlags.DecryptSSL);

I tried with these before response and before request handlers instead of OnAfterSessionComplete. In your Form1_Load():

Fiddler.FiddlerApplication.BeforeRequest += new SessionStateHandler(HandleBeforeRequest);
Fiddler.FiddlerApplication.BeforeResponse += new SessionStateHandler(HandleBeforeResponse);

And the handlers:

private void HandleBeforeRequest(Session oSession)
{
    oSession.bBufferResponse = true;
}

private void HandleBeforeResponse(Session oSession)
{
    if(oSession.fullUrl.Contains("google.com"))
    {
        richTextBox1.Invoke(new UpdateUI(() =>
        {
            richTextBox1.AppendText(oSession.GetResponseBodyAsString());

        }));
    }
}

By the way, don't know if you omitted them from your sample but I needed to add these in the constructor:

Load += Form1_Load;
FormClosing += Form1_FormClosing;

Might also be good to add this before Shutdown():

FiddlerApplication.oProxy.Detach();
Alex
  • 616
  • 10
  • 12