Skip to content

Instantly share code, notes, and snippets.

@luelista
Last active September 7, 2017 14:51
Show Gist options
  • Save luelista/8438427640a19cf80bde1ac175bd29b4 to your computer and use it in GitHub Desktop.
Save luelista/8438427640a19cf80bde1ac175bd29b4 to your computer and use it in GitHub Desktop.
generate certificate for android MITM and put it in system trust store
openssl genrsa -out rootCA.key 2048 -nodes
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
openssl pkcs12 -export -in rootCA.pem -out rootCA.pkcs12 -inkey rootCA.key -name "fooCA"
certhash=$(openssl x509 -in rootCA.pem -subject_hash_old -noout)
cat rootCA.pem > $certhash.0
openssl x509 -inform PEM -text -in rootCA.pem -out /dev/null >> $certhash.0
adb push rootCA.pkcs12 /sdcard
adb push $certhash.0 /sdcard
adb shell su -c "cp /sdcard/$certhash.0 /system/etc/security/cacerts"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment