How do I record a sniffer session (Сharles)?

Charles is a proxy server that runs on your computer and enables you to record HTTP and HTTPS traffic of connected devices. Recorded sessions help support teams quickly diagnose problems related to loading and displaying ads, because they contain the data of the requested ad unit, ad placement parameters, information about served banners, and technical specifications of the device.

Installing Charles

  1. You can download Charles from the official website.
  2. If the app offers to automatically configure the network settings when you launch it for the first time, click Grant Privileges.
  3. The app is free during a 30-day trial. If you have a license key, in the Charles menu, select Help → Register Charles and register the app.

For detailed information about how to use the app, see the Charles documentation.

Configuring a proxy

Once the app is installed on your computer, you can enable it to record the traffic of a mobile device by following these steps:

  1. In the Charles menu, select Proxy → SSL Proxying Settings.
  2. Activate the option Enable SSL Proxying.
  3. Click Add under Include Location and enter an asterisk in the Host field. Save the changes.
  4. In the Charles menu, select Help → SSL Proxying → Install Root Certificate on a Mobile Device or Remote Browser. After this, you should see the IP address and port of the proxy server that correspond to the IP address of your computer and the default port 8888.
  5. Restart Charles.
  6. Connect your mobile device to the same Wi-Fi network as your computer. Go to the network's settings, select Manual, and enter the IP address and port of the proxy server.

Installing the certificate

To record HTTPS traffic, install the Charles root SSL certificate on your mobile device. Learn more in the Charles documentation.

  1. Using your default browser, download the certificate at the following link: http://chls.pro/ssl.
    Note. If the certificate can't be downloaded, it's possible that the firewall on your computer is blocking incoming connections. In the firewall settings, allow Charles to accept incoming connections and try again.
  2. If the certificate installation doesn't start automatically, find the certificate installation section in the device settings and install the Charles certificate. Set Credential use to “VPN and apps”. If you need to set a PIN, enter one in the corresponding field.
  3. For Android 10 and higher, configure the app (APK) that requests the ads:
    • In the res/xml folder, create a network_security_config.xml file containing the following text:
       <?xml version="1.0" encoding="utf-8"?>
          <network-security-config>
              <base-config>
                  <trust-anchors>
                      <!-- Trust preinstalled CAs -->
                      <certificates src="system" ></certificates>
                      <!-- Trust user added CAs -->
                      <certificates src="user" ></certificates>
                  </trust-anchors>
              </base-config>
          </network-security-config>
    • Add an attribute for the application section in AndroidManifest.xml:
      <manifest>
          ...
          <application android:networkSecurityConfig="@xml/network_security_config">
              ...
          </application>
      </manifest>

Recording a session

To start or stop recording traffic, click  /  on the Charles toolbar. When recording is in progress, the button looks like this: .

Refresh the screen in the app that requests the ads. Make sure that the ad download URL appears in the session: mobile.yandexadexchange.net/v4/ad. In the Charles menu, select File → Save Session As... and save the file with the .chls extension.

Tip. Once you're done debugging, delete the certificate from your device and disable the proxy server.