No ratings

Using Fiddler to capture K2 Host Server requests

 

Using Fiddler to capture K2 Host Server requests

This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.

This should be done for debugging purposes, i.e. when you want an easy way to redirect all K2 HostServer web traffic to go through Fiddler.

 

Running Fiddler with this method should only be done for debugging purposes and never on Production Systems.

There is a wide range of issues that can be debugged using these instructions, from SmartAction Notifications, K2 for SharePoint Applications and even SmartForms.

 

Configuring Your System to Use Fiddler for Debugging

 

Please follow these instructions:

  1. Download the latest copy of Fiddler using this link and install it on your K2 Server
  2. Stop the K2 Blackpearl service.
  3. Open "\K2 blackpearl\Host Server\Bin\K2HostServer.exe.Config" with a text editor.
  4. Add the following code to the <system.net> section after editing the proxyaddress value to match your environment.

<defaultProxy enabled="true" useDefaultCredentials = "true">

    <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:9999" usesystemdefault="false" />

</defaultProxy>

These values are from the Denallix core’s Fiddler config so please adjust accordingly for your environment!

To get the values for the "proxyaddress" element open Fiddler, and select Tools > Options and click on the Connections tab.

Click on the link "Copy Browser Proxy Configuration URL" and paste the link into a text editor, the contents should look as follows:
file:///C:/Users/Admin/Documents/Fiddler2/Scripts/BrowserPAC.js

Locate the JS file and edit in a Text Editor, the contents of the file should look as follows:
function FindProxyForURL(url, host){
return 'PROXY 127.0.0.1:9999';
}

You can use the IP and Port in the "proxyaddress" element.

5. Start the K2 Blackpearl Service.

6. When saving the Fiddler Trace, make sure to save it as a .saz file (Session Archive)

 

Gareth_0-1627303112193.png
7. Next, open the “Customize Rules” in Fiddler, this is the FiddlerScript.
Keelan_0-1629460800138.png

Edit the OnBeforeRequest static function in FiddlerScript and replace the ‘host name’ placeholder with your environment’s host name:

Static function OnBeforeRequest (oSession: Session) {
       if (oSession.host.Contains("host-name")) {
            oSession["https-Client-Certificate"] = "C:\\temp\\EnvOwner.cer";
        }else{
            oSession["https-Client-Certificate"] = "C:\\temp\\EnvContributor.cer";
        }
Keelan_1-1629460933249.png

Save the script

8. Open the Certificate Manager by pressing “Windows + R” and searching “certlm.msc”

Keelan_2-1629460983888.png
9. Export the Environment Owner and Environment Contributor certs to c:\temp with the names EnvOwner.cer and EnvContributor.cerKeelan_3-1629461007124.png
  • There is no need to export the private key.
  • These files are used for the FiddlerScript to work
  • Restart Fiddler
  • Start the K2 Server

 

Your host server will route all web traffic through Fiddler. You can disable this by changing the enabled flag to false as indicated below, then restarting the host server.

<defaultProxy enabled="false" useDefaultCredentials = "true">

    <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:9999" usesystemdefault="false" />

</defaultProxy> 

Once you enable host server traffic through Fiddler you’ll start to see entries like the following:
(The following example is when K2 is getting OAuth Tokens):

Image

 

If your browser is set to "Autodetect proxy settings" these settings might override the browser proxy settings (even if set to enabled=false.

Once you have completed your debugging tests, remove the 'defaultProxy' section and restart your K2 Blackpearl Server.

Labels: (3)
Version history
Last update:
‎03-15-2022 07:36 AM
Updated by: