Skip to content

Instantly share code, notes, and snippets.

@carlonzo
Created April 4, 2023 17:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlonzo/2fae71e6b6dfa72def29d93b18323c9a to your computer and use it in GitHub Desktop.
Save carlonzo/2fae71e6b6dfa72def29d93b18323c9a to your computer and use it in GitHub Desktop.
Setup mitmproxy certificate on a new android emulator
# Following instructions in https://docs.mitmproxy.org/stable/howto-install-system-trusted-ca-android/#instructions-for-api-level--28-1
# Use and emulator with API level 28 or lower
# Start the emulator with: emulator -avd <avd name> -writable-system
set -x
set -e
root_result=$(adb root)
if [[ $root_result == "restarting adbd"* ]]; then
adb wait-for-device
fi
adb remount
# copy the certificate to the emulator
cd ~/.mitmproxy/
hashed_name=`openssl x509 -inform PEM -subject_hash_old -in mitmproxy-ca-cert.cer | head -1`
android_cert_name="$hashed_name.0"
cp mitmproxy-ca-cert.cer $android_cert_name
adb push $android_cert_name /system/etc/security/cacerts/
adb shell chmod 644 /system/etc/security/cacerts/$android_cert_name
echo "Enjoy! You may need to reboot the emulator."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment