Home » Android » proxy – Add certificate as trust on android in command line (adb)-Exceptionshub

proxy – Add certificate as trust on android in command line (adb)-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

I have a project where I need to script some actions on the android emulator but I got a problem for add a Burp certificate, to attach a proxy to my emulator.

When I add a certificate thanks to this script:

openssl x509 -inform DER -in cacert.der -out cacert.pem
hash=$(openssl x509 -inform PEM -subject_hash_old -in cacert.pem | head -n -1)
mv cacert.pem $hash.0
adb.shell("mount -o rw,remount,rw /system")
adb.push("$hash.0", "/system/etc/security/cacerts/$hash.0")
adb.shell("chmod 644 /system/etc/security/cacerts/$hash.0")
adb.shell("mount -o ro,remount,ro /system")

It works I can intercept the traffic, but I have a warning for each interception as it follow:

enter image description here
enter image description here

I know that I should added this cerificate as trust. I know how to do it with the graphical interface but I want to find a way to do it in command line with adb.

Thanks

How to&Answers: