FiddlerCore SSL was working, now isn't!

7 posts, 1 answers
  1. N
    N avatar
    5 posts
    Member since:
    Apr 2015

    Posted 10 Apr 2015 Link to this post

    Up until Monday 6th my code worked. It simply uses FiddlerCore to monitor the widgets Websocket connection and enqueue the data frames text. Later I process that text to get the "Option" price/times I want. There used to be a constant stream of OnWebSocketMessage calls but now there are none from the Websocket! Only a couple for html/gfx at the start. I can see the same data I used to get in the propper Fiddler app so know the certificates are there and working. But no longer in my app. It seems I'm doing something wrong and it was a fluke it worked before? Or SSL was not used but now is after they updated? Please help!

    01.//certmaker.exe is in debug dir
    02.//see Log_OnLogString for output
    05.using Fiddler;
    06.public partial class App : Application
    08.    protected override void OnStartup(StartupEventArgs e)
    09.    {
    10.        //Setup internal proxy
    11.        FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;
    12.        oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy);
    13.        FiddlerApplication.Startup(0, oFCSF);
    14.        base.OnStartup(e);
    15.    }
    16.    protected override void OnExit(ExitEventArgs e)
    17.    {
    18.        FiddlerApplication.Shutdown();
    19.        base.OnExit(e);
    20.    }
    24.using Fiddler;
    25.using Awesomium.Core;
    26.using Awesomium.Windows.Controls;
    27.using System.Collections.Concurrent;
    29.public partial class MainWindow : Window
    31.    WebControl AweWebControl;
    32.    ConcurrentQueue<string> CQFiddlerPayloads;
    33.    public MainWindow()
    34.    {
    35.        CQFiddlerPayloads = new ConcurrentQueue<string>();
    37.        FiddlerApplication.OnWebSocketMessage += FiddlerApplication_OnWebSocketMessage;
    38.        FiddlerApplication.Log.OnLogString += Log_OnLogString;
    40.        WebCore.Initialize(new WebConfig
    41.        {
    42.            UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
    43.        });
    44.        WebPreferences prefs = new WebPreferences()
    45.        {
    46.            ProxyConfig = "" + FiddlerApplication.oProxy.ListenPort.ToString(),
    47.        };
    48.        WebSession webSession = WebCore.CreateWebSession(prefs);
    49.        AweWebControl = new WebControl();
    50.        AweWebControl.WebSession = webSession;
    51.        AweWebControl.CertificateError += AweWebControl_CertificateError;
    53.        InitializeComponent();
    55.        GridAweBrowser.Children.Add(AweWebControl);
    56.        AweWebControl.Source = new Uri("");
    58.        //create DispatcherTimer to process CQFiddlerPayloads
    59.    }
    61.    string LogString = "";
    62.    void Log_OnLogString(object sender, LogEventArgs e)
    63.    {
    64.        LogString += e.LogString + "\n";
    65.        // /Fiddler.CertMaker> Using Fiddler.DefaultCertificateProvider+MakeCertEngine for certificate generation
    66.        // [WebSocket #20] Read from Server failed... Object reference not set to an instance of an object.  <<not always!
    67.        // [WebSocket #20] Read from Client returned error: 0
    68.        // [WebSocket #20] Read from Server returned error: 0
    69.    }
    71.    void FiddlerApplication_OnWebSocketMessage(object sender, WebSocketMessageEventArgs e)
    72.    {
    73.        if (e.oWSM.FrameType == WebSocketFrameTypes.Text && e.oWSM.IsFinalFrame == true)
    74.            CQFiddlerPayloads.Enqueue(e.oWSM.PayloadAsString());
    75.    }
    77.    void AweWebControl_CertificateError(object sender, CertificateErrorEventArgs e)
    78.    {
    79.        e.Handled = EventHandling.Modal;
    80.        e.Ignore = true;
    81.    }

  2. Eric Lawrence
    Eric Lawrence avatar
    833 posts

    Posted 10 Apr 2015 Link to this post

    Howdy, N--

    It's hard to say what exactly is going wrong. If I open the url in Internet Explorer with Fiddler running, I see the expected messages appearing within the WebSocket tab.

    Which version of FiddlerCore are you using?

    If you load up a different WebSocket-using URL (e.g. do you see that you're getting messages for both insecure and secure websockets)?

    Can you explain to me the point of your CertificateError method? If FiddlerCore is properly intercepting and re-signing web traffic, your browser control should never see a certificate error. Where is the WebControl object class defined?

    Eric Lawrence

    See What's Next in App Development. Register for TelerikNEXT.

  3. N
    N avatar
    5 posts
    Member since:
    Apr 2015

    Posted 10 Apr 2015 in reply to Eric Lawrence Link to this post

    Thanks for your reply Eric! It's disheartening to have something swimming along smoothly then coming to a sudden stop! Obviously a lot of other code hinged on having the data....

    I'm using v of FiddlerCore4. 1.7.5 Awesomium.

    The page works with the above code -- lot's of calls come through! I don't know if the test is with SSL or plain text though.

    I've made the project available to you at (~17MB) if you want to have a look.

    Thank's for your help already. Hope you might come back with some idea on what else I could try.



  4. N
    N avatar
    5 posts
    Member since:
    Apr 2015

    Posted 11 Apr 2015 in reply to N Link to this post

    About the certificate error - I believe Awesomium dials home to see if the certificate is from a trusted authority. It is created by Fiddler of course so is not. That handler just skips displaying the "take me to safety" warning message and goes straight to "continue."
  5. Answer
    Eric Lawrence
    Eric Lawrence avatar
    833 posts

    Posted 13 Apr 2015 Link to this post

    Awsomium appears to properly consult the Windows Trusted Certificates store, so if FiddlerCore's root certificate is correctly trusted that event handler isn't needed and the site loads fine.

    If you update your OnWebSocketMessage handler to log the messages, it's plain that the very first thing that happens is the server sends a connection closure:

    MessageID: Server.1
    MessageType: Close
    PayloadString: 03-E8  (This is CloseReason.Normal)
    Masking: <none>

    ...and the client acknowledges that closure:

    MessageID: Client.2
    MessageType: Close
    Masking: 85-A3-3D-F9

    So, your client's connection is closed immediately.

    Why might that be?

    Well, if you run Fiddler and your app simultaneously, you'll note that the GET Request that establishes the WebSocket connection doesn't have a User-Agent header on it. Odd, eh? Maybe a bug in Awesomium?

    Ah well, easily fixed.

    Add this where you hook up the FiddlerCore handlers: 

       FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;

    And this to the body of your class:

    void FiddlerApplication_BeforeRequest(Session oSession)
     if (!oSession.oRequest.headers.Exists("User-Agent"))
       oSession.oRequest.headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko");

    Voila. Everything starts working.

    Eric Lawrence

    See What's Next in App Development. Register for TelerikNEXT.

  6. N
    N avatar
    5 posts
    Member since:
    Apr 2015

    Posted 15 Apr 2015 in reply to Eric Lawrence Link to this post

    I'm away for a couple of days and will try this when I get back and confirm it works and mark the answer. Hopefully it will and you'll be a life saver! Thank you either way for your efforts. Regards, Neil.
  7. N
    N avatar
    5 posts
    Member since:
    Apr 2015

    Posted 15 Apr 2015 in reply to N Link to this post

    Indeed, Voila! Everything starts working! I have a refreshed smile on my face.

    While I have been programming a long time for fun, I really didn't know how to go about solving this problem and I am extremely grateful to you, and others at different times, who lend their time to help others.

    Kind regards,



Back to Top