question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

certificate import in android 4.4.2 emulator

See original GitHub issue

Hi, I was trying to import the mitmproxy certificate into an emulated android 4.4.2 device. But no matter where I put the certificate (tried /scard/Download, /sdcard, /mnt/sdcard, /mnt/sdcard/Download, /storage/sdcard/Download, /storage/sdcard), the certificate import did not show the certificate (but it did show apk files in /sdcard/Download). This means that the instructions given at http://mitmproxy.org/doc/certinstall/android.html are either outdated for android 4.4.2, that this is a problem only appearing in the emulator or that I do something horribly wrong. Nevertheless, I managed to import the certificate in the end by doing:

fname=`openssl x509 -inform PEM -subject_hash_old -noout -in ~/.mitmproxy/mitmproxy-ca-cert.cer`.0
cp ~/.mitmproxy/mitmproxy-ca-cert.cer $fname
openssl x509 -inform PEM -text -noout -in ~/.mitmproxy/mitmproxy-ca-cert.cer >> $fname
adb push $fname /system/etc/security/cacerts/
adb shell chmod 644 /system/etc/security/cacerts/$fname

Maybe it would make sense to verify whether I just messed up somewhere or whether the instructions at http://mitmproxy.org/doc/certinstall/android.html indeed need updating and if they do, to also provide this new certificate format.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
0xroot-bfcommented, Jan 21, 2014

Hey josh, I had exactly the same problem that you described before, is something related with the emulator, apparently it doesn’t detect the external storage where you uploaded the certificate.

There is a workaround that may work for you, and will install the certificate as system and not as user. If you go to the following folder:

root@android:/system/etc/security/cacerts # ls
00673b5b.0
03e16f6c.0
08aef7bb.0
0d188d89.0
10531352.0
111e6273.0
1155c94b.0
...

You can see there, all the certificates installed onto your device or emulator. It’s content is something like this http://pastebin.com/DzJFbXdz

I did this script that will prepare the certificate that you may want to install with the same appearance:

#!/bin/bash

filename=`openssl x509 -in $1  -hash -noout`
> $filename".0" 

# blob data, text and fingerprint information
openssl x509 -in $1 >> $filename.0
openssl x509 -in $1  -text -fingerprint -noout >> $filename.0

adb shell busybox mount -o remount,rw /system
adb push $filename.0 /system/etc/security/cacerts

Run it as follows:

./script.sh CERT_NAME

It should work, and you should be able to see the new certificate listed in ‘Settings > Security > Trusted Cert > Systems’.

Anyway, I switched from 4.4.2 to 4.2.2, so maybe that will work for you too.

0reactions
smoothdvdcommented, Oct 11, 2016

In 7.0 emulator, use mount -o rw,remount /dev/block/vda /system to remount fs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I import a CA certificate into Android 4.4.2 in the ...
Go to Android Virtual Device Manager (sdk\tools\android. · Start your emulator but select 'Wipe user Data' when you're starting the emulator ...
Read more >
How to import a CA certificate into Android 4.4.2 in the emulator
Go to Android Virtual Device Manager (sdk\tools\android. · Start your emulator but select 'Wipe user Data' when you're starting the emulator · Copy...
Read more >
Security with network protocols - Android Developers
In addition, it isn't necessary on Android 10 or higher to have a device screen lock to import keys or CA certificates into...
Read more >
Import/Install SSL-certificate without CA-flag
Is it possible to install this self-signed certificate to Android without having a set CA-flag? Android uses OpenSSL (or the fork BoringSSL ...
Read more >
How do I install Securly SSL certificate on Android device?
Download the certificate. · Tap Settings –> Biometrics and Security –> Other Security Settings · Tap on Install Device Storage · Tap on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found