Created
April 4, 2023 17:19
-
-
Save carlonzo/2fae71e6b6dfa72def29d93b18323c9a to your computer and use it in GitHub Desktop.
Setup mitmproxy certificate on a new android emulator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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