Skip to content

Debugging Https bugs using Charles

Manuel de la Pena edited this page Jan 28, 2019 · 4 revisions

Charles is a web debugging proxy that allows to sniff the http communications with a remote server. Charles is a good tool to use to be able to debug possible issues with the network stack, specially the HttpClient and one of its implementations.

This document shows the few steps that have to be taken to be able to use Charles for debugging https calls.

Getting Started

Download Charles

You can start using Charles with its trial license which will provide you with a copy of the application that limits the amount of time the application will run. Of course, if you do find the software we recommend you to get a license ;)

The application downloads can be found here.

Installing the ssl proxy

Once the application has been installed, it is important to install the Charles CA SSL certificate in the iOS Simulators in order to be able to use see the encrypted communication.

As of version 3.9.3, Charles contains a menu item that allows the installation of the certificate in all the simulators present in your system. This menu item can be found in the Help menu under "Install Charles CA SSL Certificate in iOS Simulators" which will do the installation for you.

Development details

Testing SSL issues

In some cases you might be getting exceptions from CFNetwork regarding the SSL certificates of certain url. There is no need for you to write your own application, you can use nscurl to use the CFNetwork Apple API to test the SSL certificates and other features as background sessions:

The following command is an example on how to test the ssl certs of a known url:

nscurl --ats-diagnostics https://microsoft.com

Which will print which versions fail.

HttpClient

There are several implementations of the HttpClient, each of them might need to be set to use the system proxy in order to be able to sniff the communication.

  • Managed: Nothing needs to be done.
  • CFNetwork: Make sure that the property UseSystemProxy in the CFNetworkHandler is set to be true.
  • NSUrlSession: Nothing needs to be done.
Clone this wiki locally