13

I was needing to view the backend https requests made by my androidTV's application, but, as the calls are "https" calls I am needing to install a charles certificate (on my androidTV) to allow charles to decrypt them.

If anyone knows how to install a certificate on androidTV please tell me.

Thanks a lot!

Sebastian Corradi
  • 1,353
  • 2
  • 14
  • 25

3 Answers3

4

You can install SSL certs in the Android Emulator through ADB, given that you use an emulator image without Google Play Services. This will allow you to root your emulator and push the certificate to the cacerts directory in /system. This means you can install SSL certificates on AndroidTV even though there is no UI for this available in settings.

To install your certificate in the emulator, follow these steps:

  • Get an Android (TV) emulator without Play Services and give it a convenient name
  • Go to $ANDROID_HOME/emulator and run ./emulator @<emulatorname> -writable-system. If you run the emulator through Android Studio, you won't be able to mount the system partition as writable.
  • adb root
  • adb remount
  • openssl x509 -inform PEM -subject_hash_old -in <your certificate>.pem | head -n 1 , this will give you a hash you'll need in the following steps
  • Rename <your certificate>.pem to <hash>.0 (e.g. 711d79cc.0)
  • adb push <hash>.0 /system/etc/security/cacerts/<hash>.0
  • adb shell chmod 644 /system/etc/security/cacerts/<hash>.0
Mavamaarten
  • 1,959
  • 18
  • 19
3

I wrote an article on this: https://zahidrasheed.medium.com/charles-proxy-with-androidtv-fedc863e7039

TLDR; 1- Export root certificate from charles app and put it under res/raw by:

Help > SSL Proxying > Save Charles Root Certificate… and save it as charles_ssl_cert.pem file.

2- Embed the certificate in the app through network-security-config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <debug-overrides>
        <trust-anchors>
            <certificates src="system" />
            <certificates src="@raw/charles_ssl_cert" />
            <certificates src="user" />
        </trust-anchors>
    </debug-overrides>
</network-security-config>

3- Export the root certificate again by:

Help > SSL Proxying > Export Charles Certificate and Private Key

Now share the .p12 file with users who would like to test the app. The need to:

Proxy > SSL Proxying Settings > Root Certificate > Import P12 (Enter the password you used above).
Zahid Rasheed
  • 1,536
  • 1
  • 10
  • 28
1

You can do it programmatically. See here for more details. I haven't found an option to do it from the Android TV UI unfortunately.

EDIT: Even that fails with

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.settings/com.android.settings.CredentialStorage}; have you declared this activity in your AndroidManifest.xml?

So I don't know how to do this...

mbonnin
  • 6,893
  • 3
  • 39
  • 55