3

I use Charles Proxy on Mac OS, to debug mobile app: it works well on real devices (iOS/Android), on iOS simulator, but it's a little tricky on Android simulators (several IPs are used for the same URL).

However, I try to debug APIs Integrations Tests, and in this case, I don't see any trace in Charles Proxy...

I've tried to do this with Visual Studio for Mac and with Rider.

When I debug the test, I can see that the call is well done, but I don't see any trace in Charles Proxy, whereas when I use the same URL in the mobile app, I can see the trace easily.

Is there a specific step to do to include calls from console app or Integration Tests calls from any IDE? (Visual Studio for Mac or Rider)

In the same time, I can see all the traces coming from Chrome, Safari, Slack,... So I don't see what I could have forgotten.

After having edited the HttpClientHandler like this, I can see traces in Charles Proxy:

public class TestsHttpMessageHandlerFactory : IHttpMessageHandlerFactory
{
    public HttpMessageHandler Create()
    {
        return new HttpClientHandler
        {
            Proxy = new WebProxy("http://192.168.86.177:8888"),
            UseProxy = true
        };
    }
}

But now I have the following error details in Charles Proxy:

 - Status: Failed Failure: Client closed the connection before a request
   was made. Possibly the SSL certificate was rejected. 
 - Notes: You may need to configure your browser or application to trust the Charles Root Certificate. See SSL Proxying in the Help menu. 
 - Response Code: 200 Connection established

How to configure the certificate in my app?

Regards,

Gold.strike
  • 1,269
  • 13
  • 47
  • There is a section in the [SSL cert doc](https://www.charlesproxy.com/documentation/using-charles/ssl-certificates/) on Charles for macOS: *In Charles go to the Help menu and choose "SSL Proxying > Install Charles Root Certificate". Keychain Access will open. Find the "Charles Proxy..." entry, and double-click to get info on it. Expand the "Trust" section, and beside "When using this certificate" change it from "Use System Defaults" to "Always Trust". Then close the certificate info window, and you will be prompted for your Administrator password to update the system trust settings.* – radj Jun 02 '20 at 04:56

0 Answers0