0
votes

Is there a way to get Fiddler 4.6.2.3 to send Basic Authentication credentials to an upstream proxy ONLY when the Fiddler "Manual Proxy Configuration" has been activated? I know how to configure Fiddler to send Basic Auth credentials with every HTTP request, but I want to turn Fiddler's "Manual Proxy Configuration" feature on/off as I test my applications. When the Manual Proxy Configuration is "off" I don't want Fiddler sending Basic Auth credentials because Fiddler will be configured to use my Windows' System Proxy and its IP. When the Manual Proxy Configuration is turned "on" I want the Basic Auth credentials sent to the upstream proxy so that I can use the proxy's IP.

I know I can change this directly in IE11 (I'm on a Windows 7 Pro 64-bit laptop) settings, but I don't want to do that, because I want to manage this "on/off" functionality from a single application. In my case, I'd like this to be Fiddler. I looked for a flag associated with the "Manual Proxy Configuration" in the Debugging With Fiddler - Second Edition book, but didn't see anything. Is my request possible, and if so, how?

Thanks In Advance For Your Help -

1

1 Answers

0
votes

Thanks To Eric Lawrence (the author of Fiddler) for this answer (via e-mail).

Step 1: Click Rules>Customize. The FiddlerScript Editor will open.
Step 2: Just after the very beginning of the class Handlers { add the following code:

// Use a fixed proxy IP with Basic authentication
public static RulesOption("Use Auth-Proxy")
var bUseAuthProxy: boolean = false;

Step 3: Inside the OnBeforeRequest function (further down in the Handlers class code) add the following code:

   if (bUseAuthProxy) {
      oSession["X-OverrideGateway"] = "myAuthenticatingProxy:8080";
      oSession.RequestHeaders["Proxy-Authorization"] = "Basic yourbase64stringhere";
   }

Don't forget the closing right-brace (like I did!) in the above code snippet (it's so easy to overlook!). If you forget the right-brace, the "Use Auth-Proxy" option won't appear in the "Rules" menu.

The string "myAuthenticatingProxy:8080" is the IP and port number for your proxy server in the form of IP:Port Number. Make sure that the IP and port number are separated by a colon (":"), that it is double-quoted, and that the code line ends with a semicolon.

The string for your authentication credentials MUST start with the word "Basic" (which indicates Basic authentication as opposed to NTLM, etc., authentication). The "yourbase64stringhere" is your proxy IP authentication credentials in the form of username:password (with a colon ":" included in the string) that has been converted to a Base-64 string. Fiddler comes with a built-in Base-64 converter. Click Tools>Text Wizard. Type your username:password string into the upper panel. By default, the Text Wizard is set to convert text entered in the upper panel to a Base-64 string output in the lower panel (notice the "Transform" drop-down located between the upper and lower panels). Copy the Base-64 string that has been output in the lower panel and append it to the word "Basic" SEPARATED BY A SPACE. Put double-quotes around the entire string and end the line of code with a semicolon.

Step 4: Save the file. Click the Rules entry on the main Fiddler menu. You should now see a rule item named "Use Auth-Proxy". Clicking this entry will configure Fiddler to use the IP and authentication credentials you coded in Step 3. Unchecking the "Use Auth-Proxy" reverts Fiddler to using whatever configuration has been established under Tools>Fiddler Options>Gateway. This is a very efficient way to "select" and "unselect" a specific proxy during application development. Thanks again Eric for the great solution!

-- Bill Vallance