In #58922, the following user trust store directory was added to crypto/x509 for Android:
|
"/data/misc/keychain/certs-added", // User trusted CA folder |
However, Android hasn't used this path since 2014 and instead uses /data/misc/user/<user ID>/cacerts-added, where <user ID> is the Android user ID (not Linux/POSIX UID).
I'm not sure if there's a good public API to get the user ID. UserHandle.myUserId() (on the Java side) is not public. However, the Android user ID is implemented as getuid() / 100000. As far as I can tell, this has never changed since Android got multi-user support ~14 years ago. Maybe it's good enough to rely on this implementation detail?
Some links:
Side note: For system CA certs, golang currently only loads /system/etc/security/cacerts, but ever since Android 14, the system CA certs became updatable and /apex/com.android.conscrypt/cacerts should have priority: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-15.0.0_r12/core/java/android/security/net/config/SystemCertificateSource.java#48
In #58922, the following user trust store directory was added to crypto/x509 for Android:
go/src/crypto/x509/root_linux.go
Line 29 in 6da1601
However, Android hasn't used this path since 2014 and instead uses
/data/misc/user/<user ID>/cacerts-added, where<user ID>is the Android user ID (not Linux/POSIX UID).I'm not sure if there's a good public API to get the user ID.
UserHandle.myUserId()(on the Java side) is not public. However, the Android user ID is implemented asgetuid() / 100000. As far as I can tell, this has never changed since Android got multi-user support ~14 years ago. Maybe it's good enough to rely on this implementation detail?Some links:
/data/misc/user/<user ID>/cacerts-addedfor the Java TLS stack/data/misc/keychain/certs-addeddirectorySide note: For system CA certs, golang currently only loads
/system/etc/security/cacerts, but ever since Android 14, the system CA certs became updatable and/apex/com.android.conscrypt/cacertsshould have priority: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-15.0.0_r12/core/java/android/security/net/config/SystemCertificateSource.java#48