From 314b84808c9401efb0a676e0082b605d20393aaa Mon Sep 17 00:00:00 2001 From: KoheiYamashita Date: Sun, 1 Mar 2026 04:18:58 +0900 Subject: [PATCH] fix: set CA certificate path for CGO_ENABLED=0 Android builds The pure-Go TLS stack cannot find CA certificates on Android because they are at /system/etc/security/cacerts instead of standard Linux paths. Set SSL_CERT_DIR when no cert env vars are configured. Co-Authored-By: Claude Opus 4.6 --- cmd/clawdroid/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/clawdroid/main.go b/cmd/clawdroid/main.go index 857d3275e..0a8d027b2 100644 --- a/cmd/clawdroid/main.go +++ b/cmd/clawdroid/main.go @@ -123,6 +123,15 @@ func init() { net.DefaultResolver.Dial = func(ctx context.Context, network, address string) (net.Conn, error) { return (&net.Dialer{}).DialContext(ctx, "udp", "8.8.8.8:53") } + + // Set CA certificate location for CGO_ENABLED=0 builds (Android APK). + // The pure-Go TLS stack cannot find Android's CA certs at their + // non-standard path. Only set if not already configured. + if os.Getenv("SSL_CERT_FILE") == "" && os.Getenv("SSL_CERT_DIR") == "" { + if _, err := os.Stat("/system/etc/security/cacerts"); err == nil { + os.Setenv("SSL_CERT_DIR", "/system/etc/security/cacerts") + } + } } func main() {