Easy Setup Charles Proxy to Intercept HTTPS traffic of Android Emulator

Kidd Tang
Dev Genius
Published in
3 min readMar 19, 2021

--

For Web or App development, typically you are required to debug and look into the HTTPS traffic of your applications. To intercept the traffic, you have to use the Man-in-the-middle technique to decrypt and encrypt between your application and the API endpoint.

Let’s us walkthrough in detail with Android Emulator …

A. Setup Android Emulator (in Android Studio)

You have to use the emulator system image without Play Store

Pick the image without Play Store Icon
Using Android Q
(Optional) Show Advanced Settings → Set to “Cold boot”

New folder storing the emulator will be created at %USERPROFILE%\.android\avd

B. Export Root Certificate

Save the Charles Root Certificate

Rename this “pem” file to android specific format certificate file.

You can use the openssl in Git Bash

openssl x509 -inform PEM -subject_hash_old -in charles.pem | head -1

name format as “<hash-value>” + “.0”
(simply concatenate “.0” as a string with the hash value string)

C. Start Emulator

Emulator Path in Windows
%LOCALAPPDATA%\Android\Sdk\emulator

cd %LOCALAPPDATA%\Android\Sdk\emulator emulator -avd Pixel_3a_XL_API_29 -writable-system -no-snapshot-load

D. Root & Push Root Certificates

ADB Path in Windows
%LOCALAPPDATA%\Android\Sdk\platform-tools

Execute the commands with the adb

  • For Android Q and above (API Level ≥ 29)
adb root 
adb shell avbctl disable-verification
adb reboot
adb root 
adb remount
adb push 4a40cad5.0 /system/etc/security/cacerts/
adb -e shell chmod 644 /system/etc/security/cacerts/4a40cad5.0
adb reboot
  • For Older Android (API Level < 29)
adb root 
adb remount
adb push 4a40cad5.0 /system/etc/security/cacerts/
adb -e shell chmod 644 /system/etc/security/cacerts/4a40cad5.0
adb reboot

E. Verify Trusted Cert & Setting APN

  1. Settings → Security → Encryption & Credentials → Trusted credentials

2. Disable Wi-Fi

3. Network & Internet → Mobile network → Advanced → Access Point Names

Set Name, APN with any value, Proxy & Port should follow Charles Proxy

4. Select the APN

5. Verification

If the proxy configuration mismatched, or Charles not launched
if everything works properly

Once you completed all the steps above, you should be able to see all the encrypted traffic sending from your Android Emulator!

--

--

Full-stack web developer with electronic engineering background.