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 <noreply@anthropic.com>
This commit is contained in:
parent
c0babbc643
commit
314b84808c
1 changed files with 9 additions and 0 deletions
|
|
@ -123,6 +123,15 @@ func init() {
|
||||||
net.DefaultResolver.Dial = func(ctx context.Context, network, address string) (net.Conn, error) {
|
net.DefaultResolver.Dial = func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
return (&net.Dialer{}).DialContext(ctx, "udp", "8.8.8.8:53")
|
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() {
|
func main() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue