Repository navigation
TLS: Load Android system CA store when default root pool is empty - #7098
Raycc-lang wants to merge 3 commits into
Conversation
Official releases are built with GOOS=linux. Go only searches /etc/ssl/certs and /etc/pki/tls/certs for system roots on GOOS=linux; /system/etc/security/cacerts is only added for GOOS=android builds. Neither default path exists on Android, so Xray ends up with an empty root pool there and every outbound TLS handshake fails with x509: certificate signed by unknown authority. This is a common deployment (rooted devices running the linux/arm64 binary via Magisk/KernelSU modules such as box_for_root). When the system pool comes back empty on linux, fall back to loading the Android system CA store directly.
|
maybe |
|
Thanks, this looks like a simpler way to address the empty root pool. The trade-off is that it would use the bundled Mozilla/NSS roots rather than Android’s system CA store, so the dependency would need to stay updated. Would you prefer that approach? |
|
|
机器人会更新它的 而且它的本质只是给不标准的设备追加一个后备证书库 不是主要机制 应该不会有人服务端使用非常新的根证书还在安卓上跑xray的Linux build还用几年前的旧版本xray |
Added a comment explaining the purpose of the file for Linux ARM builds on Android.
|
@Fangliding 话说 Golang 这个 CA 库有哪些根证书? @Raycc-lang 这个 PR 改成 @Fangliding 说的然后默认不 load 系统 CA 库,TLS 加个选项才使用系统 CA 库吧 |
|
那算了还是我弄吧 |
…iously injected CA in the OS) (#7105) #5532 (comment) #7098 (comment) #7105 (comment)
Problem
Official Linux ARM binaries can run on rooted Android, but Go's default Linux certificate locations do not include Android's CA store. On the affected device,
x509.SystemCertPool()was empty and verified outbound TLS connections failed with:The original reproduction used the official linux-arm64 release:
Fix
Replace the initial Android directory-loading implementation with
golang.org/x/crypto/x509roots/fallback, imported bymain/distro/allunderlinux && (arm || arm64).transport/internet/tls/config_other.goto its original implementation; existingSystemCertPool()calls obtain the fallback pool.v0.0.0-20261005185213-c3db4df58582.Validation of the current revision
Using Go 1.27.1:
disableSystemRootretained a custom-only pool, or an empty pool when no certificates were configured.go mod verifypassed.The current fallback implementation has not yet been tested on the Android device: the cloud development environment has no ADB/device connection. The earlier on-device success reported for this PR applied to the original Android directory-loading patch, not this replacement. The full test suite was not run for this revision.