Using Fiddler to capture K2 Host Server requests

  • 15 February 2022
  • 0 replies
  • 535 views

Userlevel 5
Badge +20
 

Using Fiddler to capture K2 Host Server requests

KBS100076

PRODUCT
K2 Five
K2 blackpearl 4.6.11 to 4.7
TAGS
Debugging
K2 Designer for SharePoint
K2 Workspace
Microsoft SharePoint
Technical Guidance
SmartObjects
Management Site
Troubleshooting Tool
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 blackpearlHost ServerBinK2HostServer.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)

 

18940iE4110144B963C6C4.png
7. Next, open the “Customize Rules” in Fiddler, this is the FiddlerScript.
19343i6735F871A2263B46.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";
        }
19344i6E5D2D8788D2E9E9.png

Save the script

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

19345i0310385504867924.png
9. Export the Environment Owner and Environment Contributor certs to c: emp with the names EnvOwner.cer and EnvContributor.cer19346i617056B28C3B54A6.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.


0 replies

Be the first to reply!

Reply