Setup Charles Proxy for Android Emulators / MacOS

Rıdvan Özcan
6 min readApr 19, 2023

--

The information provided in the help section of Charles Proxy for Android emulators is outdated as of April 2023. The following step-by-step guide will assist you in setting up SSL proxying with an Android emulator in an updated and current manner.

Charles was designed as an in-depth piece of software. Launch it and follow the steps below in order. Charles will try to configure it automatically so you’ll be up and running right away. Start navigating the emulator and watch the results appear in Charles; Click on them and take a look at the saved ones.

Charles generates its own certificates for websites and signs them using a unique Charles Root Certificate that is created specifically for your installation of Charles (starting from v3.10). When your browser or other application receives a website’s certificate that was signed by the Charles Root Certificate, a warning will appear since the Charles Root Certificate is not included in your trusted root certificates list. For more information, please refer to the SSL Proxying documentation.

You can choose to trust each website’s certificate as you encounter it, and in this case, you do not need to trust the Charles Root Certificate. If you would like to automatically trust all certificates issued by Charles, follow the instructions below.

The instructions below are for various browsers and applications to help you trust the Charles Root Certificate and prevent certificate warnings from appearing.

Please note that the approach to the Charles Root Certificate changed with version 3.10 of Charles. If you have previously followed this procedure for an older version of Charles, you will need to repeat the steps again.

🔥 We start the installation 🔥

First, we download the charles application.

Download Link : https://www.charlesproxy.com/download/

  • Unzip the download file by double-clicking it, and then copy the Charles application into your Applications folder.

After the installation, we make the Charles settings on the computer.

To install the Charles Root Certificate, navigate to the Help menu in Charles and select “SSL Proxying > Install Charles Root Certificate”. A window will appear with a warning message that the CA Root certificate is not trusted.

Click the “Install Certificate” button to launch the Certificate Import Wizard. Make sure to select the “Trusted Root Certification Authorities” certificate store to import the certificate, and override any automatic certificate store selections.

Double click on the certificate

When using this certificate : Always Trust

Complete the wizard and your Charles Root Certificate is now installed. You may need to restart program.

Now that the installations on the computer are finished, we are now making the settings in the Android emulator.

As of Android N, you need to add configuration to your app in order to have it trust the SSL certificates generated by Charles SSL Proxying. This means that you can only use SSL Proxying with apps that you control.

First we need to change the proxy settings of our android emulator.

In new android studio versions, the emulator is embedded in android studio and proxy settings cannot be made. Therefore, we need to ectract the emulator externally. You can extract the emulator externally by following the steps below.

1- Android Studio -> Settings -> Search (Emulator)

As you can see in the picture, launch in a tool window checkbox should not be selected.

Now we can run the emulator again.

We need the proxy and port number so that we can set the proxy settings in the emulator. You can get this information by following the steps below.

Navigate to the Help menu in Charles and select “SSL Proxying > Install Charles Root Certificate on a Mobile Device or remote Browser”.

When we click the Install Charles Root Certificate on a Mobile Device or remote Browser button, a message will appear. In this message, where starting with HTTP proxy, we have our proxy number followed by our port number.
For example, my proxy number: 198.168.0.101, my port number: 8888

Yes, now we have proxy and port numbers. It’s time to change the proxy settings in the emulator.

Click on the 3 dots on the right of the emulator.

On the screen that opens, we first click on the Settings button in the left menu. Then we click on the Proxy option in the section that opens on the right. Then we select the Manual proxy configuration option, enter the proxy and port information we have and click apply.

After making the proxy settings of the emulator, we need to install the charles proxy’s certificate in the wife certificate section of our emulator.

Download Certificate : http://chls.pro/ssl

After downloading the certificate from the link above, we need to put this certificate in the download folder of our emulator. You can assign the certificate to the emulator’s download folder by following the steps below.

Click the Device File Explorer button from the menu at the bottom right of Android studio.
Then, in the section that opens, we select our own emulator, go to sdcard -> Download folder, and drag and drop our certificate here.

It’s time to configure the Wi-Fi settings of our emulator. Settings → Search ( Wi-Fi certificate) via emulator

We click on the Wi-Fi certificate button, then we click on the Wi-fi certificate button again on the screen that opens

It will ask us to choose the certificate we have installed in the download folder. On the screen that opens, we go to the Download folder and select the certificate. You can enter CA certificate in the name of the certificate.

We have successfully completed all our settings on the emulator. 🔥

It’s time to make the code settings in the project.

Add a file res/xml/network_security_config.xml to your app:

<network-security-config> 
<debug-overrides>
<trust-anchors>
<!-- Trust user added CAs while debuggable only -->
<certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>

Then add a reference to this file in your app’s manifest, as follows:

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="@xml/network_security_config" ... >
...
</application>
</manifest>

We have completed all the procedures. We can run our application and see that the network traffic is reflected on the charles program. 🔥🔥🔥

Note : If the responses appear encrypted or mixed, right-click on the http request and click the Enable SSL Proxying button from the pop-up menu.

--

--