Skip to content

Commit be3a2d3

Browse files
committed
Fix certificate explanation on Android < v7
On older devices, we don't need to warn about user-certificate caveats, because user certificates will be trusted like system certificates. On such devices, when a certificate is trusted by the user but not the system, we now show a simplified "Certificate Trusted" message that makes this clearer.
1 parent 55a3844 commit be3a2d3

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

app/src/main/java/tech/httptoolkit/android/ConnectionStatusView.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ class ConnectionStatusView(
2323

2424
init {
2525
val layout = when (whereIsCertTrusted(proxyConfig)) {
26-
"user" -> R.layout.connection_status_user
26+
"user" ->
27+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
28+
R.layout.connection_status_pre_v7
29+
else
30+
R.layout.connection_status_user
2731
"system" -> R.layout.connection_status_system
2832
else -> R.layout.connection_status_none
2933
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:orientation="vertical"
7+
android:paddingStart="16dp"
8+
android:paddingEnd="16dp"
9+
android:paddingBottom="4dp"
10+
android:clipToPadding="false">
11+
12+
<include layout="@layout/connected_text" />
13+
14+
<com.google.android.material.card.MaterialCardView
15+
style="@style/ConnectionStatusCard"
16+
android:layout_width="match_parent"
17+
android:layout_height="wrap_content">
18+
19+
<LinearLayout
20+
android:layout_width="match_parent"
21+
android:layout_height="match_parent"
22+
android:orientation="vertical">
23+
24+
<TextView
25+
style="@style/ConnectionStatusHeading"
26+
android:drawableStart="@drawable/ic_check_circle"
27+
android:text="@string/pre_v7_connection_status_enabled_heading" />
28+
29+
</LinearLayout>
30+
</com.google.android.material.card.MaterialCardView>
31+
32+
<include layout="@layout/app_interception_status" />
33+
34+
</android.widget.LinearLayout>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:orientation="vertical"
7+
android:paddingStart="16dp"
8+
android:paddingEnd="16dp"
9+
android:paddingBottom="4dp"
10+
android:clipToPadding="false">
11+
12+
<include layout="@layout/connected_text" />
13+
14+
<com.google.android.material.card.MaterialCardView
15+
style="@style/ConnectionStatusCard"
16+
android:layout_width="match_parent"
17+
android:layout_height="wrap_content">
18+
19+
<LinearLayout
20+
android:layout_width="match_parent"
21+
android:layout_height="match_parent"
22+
android:orientation="vertical">
23+
24+
<TextView
25+
style="@style/ConnectionStatusHeading"
26+
android:drawableStart="@drawable/ic_check_circle"
27+
android:text="@string/pre_v7_connection_status_enabled_heading" />
28+
29+
<TextView
30+
style="@style/ConnectionStatusText"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:text="@string/pre_v7_connection_status_details" />
34+
35+
</LinearLayout>
36+
</com.google.android.material.card.MaterialCardView>
37+
38+
<include layout="@layout/app_interception_status" />
39+
40+
</android.widget.LinearLayout>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
<string name="user_connection_status_enabled_heading">User trust enabled</string>
2121
<string name="system_connection_status_disabled_heading">System trust disabled</string>
2222
<string name="system_connection_status_enabled_heading">System trust enabled</string>
23+
<string name="pre_v7_connection_status_enabled_heading">Certificate trusted</string>
2324

2425
<string name="none_connection_status_details">Your HTTP Toolkit certificate is not trusted on this device, so HTTPS traffic will only be available from apps that individually include and trust it.\n\nDisconnect and reconnect to rerun HTTPS certificate setup.</string>
2526
<string name="user_connection_status_details">HTTPS interception will only be available for apps that are configured to trust user-installed certificates (<a href="https://httptoolkit.tech/docs/guides/android#intercepting-traffic-from-your-own-android-app">How?</a>)</string>
2627
<string name="system_connection_status_details">Traffic from all intercepted applications will be available, except those using explicit certificate pinning.</string>
28+
<string name="pre_v7_connection_status_details">Traffic from all intercepted applications will be available, except those using explicit certificate pinning.</string>
2729

2830
<string name="scan_button">Scan QR code</string>
2931
<string name="reconnect_button">Reconnect</string>

0 commit comments

Comments
 (0)