@@ -3,27 +3,22 @@ MODDIR=${0%/*}
33
44# Android hashes the subject to get the filename, field order is significant.
55# (`openssl x509 -in ... -noout -hash`)
6- # AdGuard's primary certificate is "/C=EN/O=AdGuard/CN=AdGuard Personal CA".
7- # AdGuard's intermediate certificate is "/C=EN/O=AdGuard/CN=AdGuard Personal Intermediate".
6+ # AdGuard's certificate is "/C=EN/O=AdGuard/CN=AdGuard Personal CA".
87# The filename is then <hash>.<n> where <n> is an integer to disambiguate
98# different certs with the same hash (e.g. when the same cert is installed repeatedly).
109#
1110# Due to https://github.com/AdguardTeam/AdguardForAndroid/issues/2108
12- # 1. Retrieve the most recent primary and intermediate certificates with our hash from the user store.
13- # It is assumed that the last installed AdGuard's certs are the correct ones.
14- # 2. Check the existence of AdGuard's intermediate certificate. If the certificate is not present,
15- # the steps 3 and 4 will be skipped.
16- # 3. Copy the primary AdGuard certificate to the system store under the name "<hash>.0".
11+ # 1. Retrieve the most recent certificate with our hash from the user store.
12+ # It is assumed that the last installed AdGuard's cert is the correct one.
13+ # 2. Copy the AdGuard certificate to the system store under the name "<hash>.0".
1714# Note that some apps may ignore other certs.
18- # 4 . Remove all certs with our hash from the `cacerts-removed` directory.
15+ # 3 . Remove all certs with our hash from the `cacerts-removed` directory.
1916# They get there if a certificate is "disabled" in the security settings.
2017# Apps will reject certs that are in the `cacerts-removed`.
2118AG_CERT_HASH=0f4ed297
22- AG_INTERMEDIATE_CERT_HASH=47ec1af8
2319AG_CERT_FILE=$( ls /data/misc/user/* /cacerts-added/${AG_CERT_HASH} .* | (IFS=.; while read -r left right; do echo $right $left .$right ; done) | sort -nr | (read -r left right; echo $right ))
24- AG_INTERMEDIATE_CERT_FILE=$( ls /data/misc/user/* /cacerts-added/${AG_INTERMEDIATE_CERT_HASH} .* | (IFS=.; while read -r left right; do echo $right $left .$right ; done) | sort -nr | (read -r left right; echo $right ))
2520
26- if [ -e " ${AG_CERT_FILE} " ] && [ -e " ${AG_INTERMEDIATE_CERT_FILE} " ] ; then
21+ if [ -e " ${AG_CERT_FILE} " ]; then
2722 cp -f ${AG_CERT_FILE} ${MODDIR} /system/etc/security/cacerts/${AG_CERT_HASH} .0
2823 rm -f /data/misc/user/* /cacerts-removed/${AG_CERT_HASH} .*
2924fi
0 commit comments