This is a migrated thread and some comments may be shown as answers.

FiddlerCore SSL was working, now isn't!

6 Answers 272 Views
Windows
This is a migrated thread and some comments may be shown as answers.
N
Top achievements
Rank 1
N asked on 10 Apr 2015, 03:36 PM

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
03. 
04.//App.xaml.cs
05.using Fiddler;
06.public partial class App : Application
07.{
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.    }
21.}
22. 
23.//MainWindow.xaml.cs
24.using Fiddler;
25.using Awesomium.Core;
26.using Awesomium.Windows.Controls;
27.using System.Collections.Concurrent;
28. 
29.public partial class MainWindow : Window
30.{
31.    WebControl AweWebControl;
32.    ConcurrentQueue<string> CQFiddlerPayloads;
33.    public MainWindow()
34.    {
35.        CQFiddlerPayloads = new ConcurrentQueue<string>();
36. 
37.        FiddlerApplication.OnWebSocketMessage += FiddlerApplication_OnWebSocketMessage;
38.        FiddlerApplication.Log.OnLogString += Log_OnLogString;
39. 
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 = "http://127.0.0.1:" + FiddlerApplication.oProxy.ListenPort.ToString(),
47.        };
48.        WebSession webSession = WebCore.CreateWebSession(prefs);
49.        AweWebControl = new WebControl();
50.        AweWebControl.WebSession = webSession;
51.        AweWebControl.CertificateError += AweWebControl_CertificateError;
52. 
53.        InitializeComponent();
54. 
55.        GridAweBrowser.Children.Add(AweWebControl);
56.        AweWebControl.Source = new Uri("https://binguest.optiontime.com/binGuest/GuestMode.jsp?vendor=option-time&lang=en#classic");
57. 
58.        //create DispatcherTimer to process CQFiddlerPayloads
59.    }
60. 
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.    }
70. 
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.    }
76. 
77.    void AweWebControl_CertificateError(object sender, CertificateErrorEventArgs e)
78.    {
79.        e.Handled = EventHandling.Modal;
80.        e.Ignore = true;
81.    }
82.}

6 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 10 Apr 2015, 04:29 PM
Howdy, N--

It's hard to say what exactly is going wrong. If I open the https://binguest.optiontime.com/binGuest/GuestMode.jsp?vendor=option-time&lang=en#classic 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. http://websocketstest.com/) 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?

Regards,
Eric Lawrence
Telerik
 

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

 
0
N
Top achievements
Rank 1
answered on 10 Apr 2015, 05:08 PM

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 4.4.9.8 of FiddlerCore4. 1.7.5 Awesomium.

The websocketstest.com 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 http://www.onetowatch.co.uk/Wpf_AweFiddler.zip (~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.

 

Neil

0
N
Top achievements
Rank 1
answered on 11 Apr 2015, 08:35 AM
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."
0
Accepted
Eric Lawrence
Telerik team
answered on 13 Apr 2015, 06:31 PM
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
PayloadString:
Masking: 85-A3-3D-F9
Outbound:True:

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.

Regards,
Eric Lawrence
Telerik
 

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

 
0
N
Top achievements
Rank 1
answered on 15 Apr 2015, 01:06 PM
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.
0
N
Top achievements
Rank 1
answered on 15 Apr 2015, 04:47 PM

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,

Neil.

 

Tags
Windows
Asked by
N
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
N
Top achievements
Rank 1
Share this question
or