Skip to content

Commit cffb112

Browse files
committed
android: Trust user-supplied CAs, except on known servers
This is copied from the corresponding config in zulip-mobile, which was added in the following commit: zulip/zulip-mobile@85c3a71 Unlike in zulip-mobile, though, we don't need any adjustments in debug (or profile) builds, because we don't use the `android:usesCleartextTraffic` attribute which this would clobber. (React Native debug builds reach out to the development host over cleartext HTTP in order to support hot updates; but the Flutter development tools have the host contact the app instead, using the Dart VM protocol. It's also not clear that any Dart libraries respect the `android:usesCleartextTraffic` flag anyway.) Fixes: #461
1 parent 8c4b1ed commit cffb112

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
android:launchMode="singleTop"
1212
android:theme="@style/LaunchTheme"
1313
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
14+
android:networkSecurityConfig="@xml/network_security_config"
1415
android:hardwareAccelerated="true"
1516
android:windowSoftInputMode="adjustResize">
1617
<!-- Specifies an Android theme to apply to this Activity as soon as
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
https://github.com/zulip/zulip-flutter/issues/461 -->
11+
<trust-anchors>
12+
<certificates src="system" />
13+
<certificates src="user" />
14+
</trust-anchors>
15+
</base-config>
16+
<domain-config>
17+
<!-- But revert to the default, stricter behavior — trusting only the
18+
system CA list — where we know we can, which means for domains where
19+
we know a legitimate cert will always come from a widely-trusted CA.
20+
Specifically, we know this is the case for Zulip Cloud and other
21+
domains operated by the core Zulip developers at Kandra Labs. -->
22+
<domain includeSubdomains="true">zulipchat.com</domain>
23+
<domain includeSubdomains="true">zulip.com</domain>
24+
<domain includeSubdomains="true">zulip.org</domain>
25+
<trust-anchors>
26+
<certificates src="system" />
27+
</trust-anchors>
28+
</domain-config>
29+
</network-security-config>

0 commit comments

Comments
 (0)