Skip to content

Commit 85c3a71

Browse files
shrizzagnprice
authored andcommitted
android: Trust user-supplied CAs, except on known servers
But disable the new config in debug builds, because otherwise it clobbers the `android:usesCleartextTraffic` attribute we rely on there: https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic [greg: expanded explanatory comments; added debug fix; tested that both debug and release builds still work.] Fixes: #3312
1 parent 4e09f23 commit 85c3a71

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
<application
77
android:usesCleartextTraffic="true"
8+
tools:remove="android:networkSecurityConfig"
89
tools:ignore="GoogleAppIndexingWarning"
910
tools:targetApi="28">
1011
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

android/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@
6767
android:allowBackup="true"
6868
android:icon="@mipmap/ic_launcher"
6969
android:label="@string/app_name"
70-
android:theme="@style/AppTheme">
70+
android:theme="@style/AppTheme"
71+
android:networkSecurityConfig="@xml/network_security_config"
72+
>
7173
<activity
7274
android:name=".MainActivity"
7375
android:exported="true"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<!-- For reference on this file's semantics:
4+
https://developer.android.com/training/articles/security-config#FileFormat -->
5+
<base-config>
6+
<!-- If the user has configured additional CAs on the device, trust those
7+
too. This can be useful for an internal Zulip server in a corporate
8+
or institutional environment, and was a recurring user request:
9+
https://github.com/zulip/zulip-mobile/issues/3312 -->
10+
<trust-anchors>
11+
<certificates src="system" />
12+
<certificates src="user" />
13+
</trust-anchors>
14+
</base-config>
15+
<domain-config>
16+
<!-- But revert to the default, stricter behavior — trusting only the
17+
system CA list — where we know we can, which means for domains where
18+
we know a legitimate cert will always come from a widely-trusted CA.
19+
Specifically, we know this is the case for Zulip Cloud and other
20+
domains operated by the core Zulip developers at Kandra Labs. -->
21+
<domain includeSubdomains="true">zulipchat.com</domain>
22+
<domain includeSubdomains="true">zulip.com</domain>
23+
<domain includeSubdomains="true">zulip.org</domain>
24+
<trust-anchors>
25+
<certificates src="system" />
26+
</trust-anchors>
27+
</domain-config>
28+
</network-security-config>

0 commit comments

Comments
 (0)