Search Unity

WWW can't communicate with fiddler, HTTPS, and POST request

Discussion in 'Scripting' started by bboydaisuke, Jan 5, 2017.

  1. bboydaisuke

    bboydaisuke

    Joined:
    Jun 14, 2014
    Posts:
    67
    Hello,

    I want to capture http traffic of WWW class using Fiddler. It works great with "http GET/POST" and "https GET" requests. However, if method is POST for https request, the request can't go through fiddler.
    The problem occurs only for WWW class. Browsers or any other class such as WebRequest works without any problem like this.

    REPRO STEPS
    1. Download and install Fiddler.
    2. Configure Fiddler to capture HTTPS.
    3. Run the following code in Unity Editor.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class WwwTest : MonoBehaviour
    5. {
    6.     public void Go()
    7.     {
    8.         Debug.Log("GET to http");
    9.         StartCoroutine(Navigate("http://httpbin.org/", null));
    10.         Debug.Log("GET to https");
    11.         StartCoroutine(Navigate("https://httpbin.org/", null));
    12.  
    13.         byte[] postData = System.Text.Encoding.UTF8.GetBytes("postData=dummy");
    14.  
    15.         Debug.Log("POST to http");
    16.         StartCoroutine(Navigate("http://httpbin.org/post", postData));
    17.         Debug.Log("POST to https");
    18.         StartCoroutine(Navigate("https://httpbin.org/post", postData));
    19.     }
    20.  
    21.     IEnumerator Navigate(string url, byte[] postData)
    22.     {
    23.         WWW www = new WWW(url, postData);
    24.         yield return www;
    25.  
    26.         if (!string.IsNullOrEmpty(www.error))
    27.             Debug.LogError(url + " " + www.error);
    28.         else
    29.             Debug.Log(url + " " + www.text);
    30.     }
    31. }
    32.  
    EXPECTED BEHAVIOR

    All four HTTP/HTTPS requests complete and get captured in Fiddler.

    ACTUAL RESULT

    The 4th request (HTTPS, POST) stops working while CONNECT and eventually returns timeout error.


    Please help me to capture HTTPS POST traffic.

    P.S. My goal is capturing https requests for Unity Editor (Windows) and Windows Standalone apps. So I'll be happy for any other solution besides Fiddler. I tried WireShark but failed to decrypt HTTPS POST from WWW class.
     
  2. bboydaisuke

    bboydaisuke

    Joined:
    Jun 14, 2014
    Posts:
    67
    I tried Charles Web Debugging Proxy and Burp Suite. Both works. Looks like Fiddler has a problem.