502 error when use SendRequestAndWait() in FiddlerCore

1 Answer 231 Views
FiddlerCore
fei
Top achievements
Rank 1
fei asked on 21 Nov 2022, 04:35 AM

Environment:

FiddlerCore: v5.0.1

.Net: v6.0

Issue:

I've written a fiddle script to send another request to get the necessary info to proxy the original request via FidderClassic. It works fine with the tls1.2 protocol. But when I try to use FiddlerCore to do the same thing, I got the 502 error again(the error occured when I use FiddlerClassic without tls1.2 protocol).

Is there any insights for this issue? Thanks

 

1 Answer, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 22 Nov 2022, 11:48 AM

Hi Fei,

The first thing to note is that in your Fiddler Classic configuration, you have the "Ignore Server certificate errors" enabled, which might mask some possible issues with the server (while the same might throw an error on your server while going through the FiddlerCore requests). Check if you can execute the request without this setting.

The above said, I've tested demo applications (with NET6 and NET4.8), and I can use SendRequestAndWait alongside TLS1.2 without the described issue. Is the problem appearing only with a specific endpoint - perhaps you could test with various endpoints utilizing TLS1.2 and observe if the issue will reappear (and if so, you can send us more details or a demo project)?

 

The demo application we've made using the following code snippet:

 

// Testing with the following URL:  https://tls-v1-2.badssl.com:1012
session["x-OverrideSslProtocols"] = "ssl3;tls1.0;tls1.1;tls1.2";

if (session.oRequest.host.Contains("badssl.com"))
{
    Console.WriteLine(">>>>>>>>>>>>> SendRequestAndWait (badssl)" + session.oRequest.host);

    if (!String.IsNullOrEmpty(session["X-RetryNumber"])) return;
    for (var iRetry = 1; iRetry < 3; ++iRetry)
    {
        var oSD = new System.Collections.Specialized.StringDictionary();
        oSD.Add("X-RetryNumber", iRetry.ToString());
        var newSession = FiddlerApplication.oProxy.SendRequestAndWait(session.oRequest.headers, session.requestBodyBytes, oSD, null);
        Console.WriteLine(">>>> newSession response code: " + newSession.responseCode);
    }
}

 

Regards,
Nick Iliev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

fei
Top achievements
Rank 1
commented on 24 Nov 2022, 10:07 AM | edited

Thanks for your help @Nick IIiev, 

I resolved this issue using SendRequest and adding x-OverrideSslProtocols flag mannually like this:

                var resetEvent = new ManualResetEvent(initialState: false);
                EventHandler<Fiddler.StateChangeEventArgs> onStateChange = (sender, e) =>
                {
                    if (e.newState == Fiddler.SessionStates.Done || e.newState == Fiddler.SessionStates.Aborted)
                    {
                        resetEvent.Set();
                    }
                };
                var newSession = Fiddler.FiddlerApplication.oProxy.SendRequest(rqh, content, oSD, onStateChange);
                newSession["x-OverrideSslProtocols"] = "ssl3;tls1.0;tls1.1;tls1.2";

                resetEvent.WaitOne();

Tags
FiddlerCore
Asked by
fei
Top achievements
Rank 1
Answers by
Nick Iliev
Telerik team
Share this question
or