Skip to content

Instantly share code, notes, and snippets.

@PhilippeBoisney
Created November 16, 2019 10:56
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save PhilippeBoisney/26eb5885668259325fd7bfe4dcda61b9 to your computer and use it in GitHub Desktop.
Save PhilippeBoisney/26eb5885668259325fd7bfe4dcda61b9 to your computer and use it in GitHub Desktop.
cd ~/Library/Android/sdk/platform-tools/
# Get the hash of the mitmproxy-ca certificate.
openssl x509 -inform PEM -subject_hash_old -in ~/.mitmproxy/mitmproxy-ca.pem | head -1
# We will use this hash value, append '.0' (dot zero) and use this as the filename for the resulting Android certificate
cat ~/.mitmproxy/mitmproxy-ca.pem > c8750f0d.0
openssl x509 -inform PEM -text -in ~/.mitmproxy/mitmproxy-ca.pem -out /dev/null >> c8750f0d.0
# In an other terminal, we will start the emulator with writable /system volume
cd ~/Library/Android/sdk/emulator/
# In order to launch an available avd, we list them first.
./emulator -list-avds
./emulator -writable-system @Pixel_3a_XL_API_28
# We go back to the first terminal and we use adb tool to transfert the certificate
adb root
adb push c8750f0d.0 /storage/emulated/0/Download
# Then, we will mount the volume and get access to the shell
adb shell mount -o rw,remount /;
adb shell
# In the device Android shell, we will move the certificate inside the system partition in the folder '/system/etc/security/'
cp /storage/emulated/0/Download/c8750f0d.0 /system/etc/security/cacerts/
chmod 644 /system/etc/security/cacerts/c8750f0d.0
@abdumu
Copy link

abdumu commented Jan 18, 2024

cd $ANDROID_HOME/platform-tools 

# Get the hash of the mitmproxy-ca certificate.
openssl x509 -inform PEM -subject_hash_old -in ~/.mitmproxy/mitmproxy-ca.pem | head -1

# We will use this hash value, append '.0' (dot zero) and use this as the filename for the resulting Android certificate
cat ~/.mitmproxy/mitmproxy-ca.pem > c8750f0d.0
openssl x509 -inform PEM -text -in ~/.mitmproxy/mitmproxy-ca.pem -out /dev/null >> c8750f0d.0

# In an other terminal, we will start the emulator with writable /system volume
cd $ANDROID_HOME/emulator/

# In order to launch an available avd, we list them first.
./emulator -list-avds
./emulator -writable-system @Pixel_3a_XL_API_28

# We go back to the first terminal and we use adb tool to transfert the certificate
adb root
adb push c8750f0d.0 /storage/emulated/0/Download

# Then, we will mount the volume and get access to the shell
adb shell mount -o rw,remount /;
adb shell

# In the device Android shell, we will move the certificate inside the system partition in the folder '/system/etc/security/'
cp /storage/emulated/0/Download/c8750f0d.0 /system/etc/security/cacerts/
chmod 644 /system/etc/security/cacerts/c8750f0d.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment