Skip to content

crypto/x509: incorrect user trust store directory is used for Android #71258

Description

@chenxiaolong

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-AndroidmobileAndroid, iOS, and x/mobile

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions