Trust user-installed CA certificates (self-hosted servers behind a private CA)

未关闭
#317 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
50/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, kotlin
领域
mobile, security

调研方向

The trust configuration lives in app/src/main/res/xml/network_security_config.xml, whose base-config has no trust-anchors element. Check that the manifest points to this file, then read how the app builds its HTTPS client for server pairing. The maintainer has not chosen between the three options, so confirm the approach in the thread before editing. Done means a user-installed CA is accepted when pairing with a server behind a private CA.

由索引模型根据 Issue 内容生成。

描述

Problem

Pairing with an OpenCode server whose TLS certificate is signed by a private root CA
fails with -1202 serverCertificateUntrusted, although the root CA is installed on the
device (Settings → Security → Encryption & credentials → Trusted credentials → User).
Chrome on the same device opens the same URL without any certificate warning, so the
CA, the certificate chain and the SAN are all valid.

This is a common setup for self-hosted servers: a reverse proxy (nginx here) with a
certificate from a personal CA, reachable on the local network.

Environment
  • App: OpenCode 0.8.6 (1015), installed from Google Play
  • Server: nginx 1.27 terminating TLS in front of OpenCode, certificate signed by a private
    root CA (RSA 2048, SHA-256, SAN matches the hostname, full chain served)
Error
URLError -1202 serverCertificateUntrusted · https://<host>:<port>
Phase: Pair
Message: Couldn't reach the OpenCode server
Cause

app/src/main/res/xml/network_security_config.xml only sets
<base-config cleartextTrafficPermitted="true" /> without <trust-anchors>.
On Android 7+ this means only system CAs are trusted; user-installed CAs are ignored.

Possible solutions

Any of these would solve it:

  1. Trust user CAs in the network security config (smallest change):
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />
        </trust-anchors>
    </base-config>
    
  2. A toggle in Settings, e.g. "Trust user-installed certificates", off by default.
    Since the network security config is static, this would need an OkHttp
    X509TrustManager that combines the system store with the user CAs
    (AndroidCAStore) when the toggle is on.
  3. Importing a root CA in the app, e.g. per server under Edit Server, stored in
    the app's own trust store. This works without installing the CA system-wide and
    limits trust to that one server.

Option 1 matches what Chrome already does; options 2 and 3 give users more explicit
control.

主要语言
Kotlin
星标
146
派生
35
平均合并
7 小时 41 分钟
30 天内合并 PR
221

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode-android 的其他 Issue

查看 anomalyco/opencode-android 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。