FiddlerCore - Decrypt only some HTTPS requests

1 Answer 45 Views
FiddlerCore
Oskar
Top achievements
Rank 1
Oskar asked on 03 Jan 2024, 06:04 PM
Hi, is it possible to only decrypt some HTTPS requests?
I only need to decrypt some specific, and since using
.DecryptSSL()
Will decrypt all HTTPS traffic, which is what I don't want. I only need to decrypt on specific URLs.
I found this example: https://docs.telerik.com/fiddlercore/basic-usage/capture-https-traffic#fiddlerapplicationbeforeresponse
But it looks to be for the actual Fiddler Application, not for the Core version, so I'm not sure if it will work, will the <session>.uriContains even work if DecryptSSL is not enabled, will it even find the sessions?

Thanks

1 Answer, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 04 Jan 2024, 06:27 AM

Hi Oskar,

You can decrypt only specific urls by using the x-no-decrypt session flag. You just need to set it for all the sessions which you want to skip. It is important to do this in the early stages of the session creation, i.e. in the OnBeforeRequest handle. Here's an example code that should do the job:

static async Task Main(string[] args)
{
        // add handler for the BeforeRequest event - you will skip the unneeded sessions in it.
        FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;

        // Ensure you have DecryptSSL in the startup settings
        FiddlerCoreStartupSettings startupSettings =
                                new FiddlerCoreStartupSettingsBuilder()
                                    .ListenOnPort(8887)
                                    .DecryptSSL()
                                    .RegisterAsSystemProxy()
                                    .Build();

        FiddlerApplication.Startup(startupSettings);
}

private static void FiddlerApplication_BeforeRequest(Session oSession)
{
        // the x-no-decrypt must be set on the CONNECT sessions
        // with the current code, only sessions to example.com will be decrypted
        if (oSession.HTTPMethodIs("CONNECT") && !oSession.HostnameIs("example.com"))
        {
             oSession["x-no-decrypt"] = "do not care.";
        }
}

Regards,
Rosen Vladimirov
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.

Tags
FiddlerCore
Asked by
Oskar
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Share this question
or