Skip to content

Instantly share code, notes, and snippets.

@cbachert
Created March 26, 2017 20:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save cbachert/e580f1ac06ce196a9831beda349fcfa3 to your computer and use it in GitHub Desktop.
Save cbachert/e580f1ac06ce196a9831beda349fcfa3 to your computer and use it in GitHub Desktop.
Install CAcert on android via adb
#!/bin/bash
# Compiled by following instructions on https://wiki.cacert.org/FAQ/ImportRootCert
ADB="/home/christian/android-sdk-linux/platform-tools/adb"
ROOT_CRT="cacert-root.crt"
INT_CRT="cacert-class3.crt"
curl -o "$ROOT_CRT" "https://www.cacert.org/certs/root.crt"
curl -o "$INT_CRT" "https://www.cacert.org/certs/class3.crt"
ROOT_CRT_ID="$(openssl x509 -inform PEM -subject_hash_old -in $ROOT_CRT | head -1).0"
INT_CRT_ID="$(openssl x509 -inform PEM -subject_hash_old -in $INT_CRT | head -1).0"
cat $ROOT_CRT > $ROOT_CRT_ID
cat $INT_CRT > $INT_CRT_ID
openssl x509 -inform PEM -text -in $ROOT_CRT -out /dev/null >> $ROOT_CRT_ID
openssl x509 -inform PEM -text -in $INT_CRT -out /dev/null >> $INT_CRT_ID
$ADB root
$ADB shell mount -o remount,rw /system
$ADB push $ROOT_CRT_ID /system/etc/security/cacerts/
$ADB push $INT_CRT /system/etc/security/cacerts/
rm $ROOT_CRT
rm $INT_CRT
rm $ROOT_CRT_ID
rm $INT_CRT_ID
@gitnepal
Copy link

#!/bin/bash

ADB="/usr/bin/adb"

ROOT_CRT="cacert-root.crt"
INT_CRT="cacert-class3.crt"

curl -L -o "$ROOT_CRT" "https://www.cacert.org/certs/root.crt" -k
curl -L -o "$INT_CRT" "https://www.cacert.org/certs/class3.crt" -k

ROOT_CRT_ID="$(openssl x509 -inform PEM -subject_hash_old -in $ROOT_CRT | head -1).0"
INT_CRT_ID="$(openssl x509 -inform PEM -subject_hash_old -in $INT_CRT | head -1).0"

cat $ROOT_CRT > $ROOT_CRT_ID
cat $INT_CRT > $INT_CRT_ID

openssl x509 -inform PEM -text -in $ROOT_CRT -out /dev/null >> $ROOT_CRT_ID
openssl x509 -inform PEM -text -in $INT_CRT -out /dev/null >> $INT_CRT_ID

$ADB connect 192.168.0.yourip:5555
$ADB root
$ADB shell mount -o remount,rw /system
$ADB push $ROOT_CRT_ID /system/etc/security/cacerts/
$ADB push $INT_CRT /system/etc/security/cacerts/

rm $ROOT_CRT
rm $INT_CRT
rm $ROOT_CRT_ID
rm $INT_CRT_ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment