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

Offen
#317 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
50/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
android, kotlin
Bereich
mobile, security

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Kotlin
Sterne
146
Forks
35
Ø Merge
7 Std. 41 Min.
Gemergte PRs (30 T.)
221

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus anomalyco/opencode-android

Alle Issues in anomalyco/opencode-android

Ähnliche Issues

Weitere Issues zu Kotlin

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.