1
0
mirror of https://github.com/ponces/treble_aosp.git synced 2024-11-25 05:36:24 +00:00
treble_aosp/patches/trebledroid/platform_packages_apps_Settings/0003-Revert-Wi-Fi-Remove-Do-not-validate-option-in-CA-cer.patch
2024-06-18 10:56:01 +01:00

312 lines
18 KiB
Diff

From 4ca52c15a44fa6fa2e9f5f60c6f47449fd1fc546 Mon Sep 17 00:00:00 2001
From: TogoFire <italomellopereira@gmail.com>
Date: Fri, 6 Aug 2021 08:54:07 -0300
Subject: [PATCH 3/4] Revert "[Wi-Fi] Remove 'Do not validate' option in CA
certificate spinner"
This is not a definitive fix, so revert it. WPA2-Enterprise (802.1X) or
WPA2-PSK.
[xawlw]:
- Sometimes we can't connect to some Enterprise WiFi networks because we
don't know its domain so let's revert this 'Security' feature
- Read more about it here:
https://www.xda-developers.com/android-11-break-enterprise-wifi-connection/
This reverts commit 33cde5dbeee934269f16d72e26e651d56a13733e.
This reverts commit 94b8579607c6f1201cea9d6601e88cec897b2ff6.
Signed-off-by: TogoFire <italomellopereira@gmail.com>
Signed-off-by: xawlw <abdulazizawlw@gmail.com>
Change-Id: I3cec92b74a419b5463c5e5db496863e66d034703
---
res/layout/wifi_network_config.xml | 12 +++++++
res/values/strings.xml | 4 +++
.../settings/wifi/WifiConfigController.java | 33 +++++++++++++------
.../settings/wifi/WifiConfigController2.java | 33 +++++++++++++------
4 files changed, 62 insertions(+), 20 deletions(-)
diff --git a/res/layout/wifi_network_config.xml b/res/layout/wifi_network_config.xml
index 3de1a38c3ea..5e179d1fc60 100644
--- a/res/layout/wifi_network_config.xml
+++ b/res/layout/wifi_network_config.xml
@@ -237,6 +237,18 @@
android:entries="@array/eap_ocsp_type"/>
</LinearLayout>
+ <LinearLayout android:id="@+id/no_ca_cert_warning"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ style="@style/wifi_item" >
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@style/wifi_item_warning"
+ android:text="@string/wifi_do_not_validate_eap_server_warning" />
+ </LinearLayout>
+
<LinearLayout android:id="@+id/l_domain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ef93ba71132..0622daa859c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2231,6 +2231,10 @@
<string name="wifi_use_system_certs">Use system certificates</string>
<!-- Menu option for not providing an EAP user certificate -->
<string name="wifi_do_not_provide_eap_user_cert">Do not provide</string>
+ <!-- Menu option for not validating the EAP server -->
+ <string name="wifi_do_not_validate_eap_server">Do not validate</string>
+ <!-- Warning message displayed if user choses not to validate the EAP server -->
+ <string name="wifi_do_not_validate_eap_server_warning">No certificate specified. Your connection will not be private.</string>
<!-- Menu option for Trust On First Use[CHAR_LIMIT=64] -->
<string name="wifi_trust_on_first_use">Trust on First Use</string>
<!-- Warning message displayed if network name (ssid) is too long -->
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 5d45cb235b8..dc49850e7fa 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -169,6 +169,7 @@ public class WifiConfigController implements TextWatcher,
private String mMultipleCertSetString;
private String mUseSystemCertsString;
private String mDoNotProvideEapUserCertString;
+ private String mDoNotValidateEapServerString;
private Spinner mSecuritySpinner;
@VisibleForTesting Spinner mEapMethodSpinner;
@@ -275,6 +276,8 @@ public class WifiConfigController implements TextWatcher,
mUseSystemCertsString = mContext.getString(R.string.wifi_use_system_certs);
mDoNotProvideEapUserCertString =
mContext.getString(R.string.wifi_do_not_provide_eap_user_cert);
+ mDoNotValidateEapServerString =
+ mContext.getString(R.string.wifi_do_not_validate_eap_server);
if (Flags.androidVWifiApi() && mAccessPointSecurity == WifiEntry.SECURITY_WEP) {
LinearLayout wepWarningLayout =
@@ -553,7 +556,8 @@ public class WifiConfigController implements TextWatcher,
// Disallow submit if the user has not selected a CA certificate for an EAP network
// configuration.
enabled = false;
- } else if (mEapDomainView != null
+ } else if (!caCertSelection.equals(mDoNotValidateEapServerString)
+ && mEapDomainView != null
&& mView.findViewById(R.id.l_domain).getVisibility() != View.GONE
&& TextUtils.isEmpty(mEapDomainView.getText().toString())) {
// Disallow submit if the user chooses to use a certificate for EAP server
@@ -575,6 +579,7 @@ public class WifiConfigController implements TextWatcher,
}
void showWarningMessagesIfAppropriate() {
+ mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.GONE);
mView.findViewById(R.id.no_user_cert_warning).setVisibility(View.GONE);
mView.findViewById(R.id.no_domain_warning).setVisibility(View.GONE);
mView.findViewById(R.id.ssid_too_long_warning).setVisibility(View.GONE);
@@ -587,7 +592,13 @@ public class WifiConfigController implements TextWatcher,
}
if (mEapCaCertSpinner != null
&& mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
- if (mEapDomainView != null
+ String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
+ if (caCertSelection.equals(mDoNotValidateEapServerString)) {
+ // Display warning if user chooses not to validate the EAP server with a
+ // user-supplied CA certificate in an EAP network configuration.
+ mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.VISIBLE);
+ } else if (!caCertSelection.equals(mUnspecifiedCertString)
+ && mEapDomainView != null
&& mView.findViewById(R.id.l_domain).getVisibility() != View.GONE
&& TextUtils.isEmpty(mEapDomainView.getText().toString())) {
// Display warning if user chooses to use a certificate without restricting the
@@ -731,7 +742,8 @@ public class WifiConfigController implements TextWatcher,
config.enterpriseConfig.setCaCertificateAliases(null);
config.enterpriseConfig.setCaPath(null);
config.enterpriseConfig.setDomainSuffixMatch(mEapDomainView.getText().toString());
- if (caCert.equals(mUnspecifiedCertString)) {
+ if (caCert.equals(mUnspecifiedCertString)
+ || caCert.equals(mDoNotValidateEapServerString)) {
// ca_cert already set to null, so do nothing.
} else if (caCert.equals(mUseSystemCertsString)) {
config.enterpriseConfig.setCaPath(SYSTEM_CA_STORE_PATH);
@@ -765,7 +777,8 @@ public class WifiConfigController implements TextWatcher,
}
// Only set OCSP option if there is a valid CA certificate.
- if (caCert.equals(mUnspecifiedCertString)) {
+ if (caCert.equals(mUnspecifiedCertString)
+ || caCert.equals(mDoNotValidateEapServerString)) {
config.enterpriseConfig.setOcsp(WifiEnterpriseConfig.OCSP_NONE);
} else {
config.enterpriseConfig.setOcsp(mEapOcspSpinner.getSelectedItemPosition());
@@ -1070,7 +1083,7 @@ public class WifiConfigController implements TextWatcher,
loadCertificates(
mEapCaCertSpinner,
androidKeystoreAliasLoader.getCaCertAliases(),
- null /* noCertificateString */,
+ mDoNotValidateEapServerString /* noCertificateString */,
false /* showMultipleCerts */,
true /* showUsePreinstalledCertOption */);
loadCertificates(
@@ -1154,7 +1167,7 @@ public class WifiConfigController implements TextWatcher,
} else {
String[] caCerts = enterpriseConfig.getCaCertificateAliases();
if (caCerts == null) {
- setSelection(mEapCaCertSpinner, mUnspecifiedCertString);
+ setSelection(mEapCaCertSpinner, mDoNotValidateEapServerString);
} else if (caCerts.length == 1) {
setSelection(mEapCaCertSpinner, caCerts[0]);
} else {
@@ -1165,7 +1178,7 @@ public class WifiConfigController implements TextWatcher,
loadCertificates(
mEapCaCertSpinner,
androidKeystoreAliasLoader.getCaCertAliases(),
- null /* noCertificateString */,
+ mDoNotValidateEapServerString /* noCertificateString */,
true /* showMultipleCerts */,
true /* showUsePreinstalledCertOption */);
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
@@ -1298,7 +1311,8 @@ public class WifiConfigController implements TextWatcher,
if (mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
String eapCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
- if (eapCertSelection.equals(mUnspecifiedCertString)) {
+ if (eapCertSelection.equals(mDoNotValidateEapServerString)
+ || eapCertSelection.equals(mUnspecifiedCertString)) {
// Domain suffix matching is not relevant if the user hasn't chosen a CA
// certificate yet, or chooses not to validate the EAP server.
setDomainInvisible();
@@ -1559,8 +1573,7 @@ public class WifiConfigController implements TextWatcher,
}).collect(Collectors.toList()));
}
- if (!TextUtils.isEmpty(noCertificateString)
- && mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
+ if (mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
certs.add(noCertificateString);
}
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 7c9b1d1b471..3114941e8d6 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -177,6 +177,7 @@ public class WifiConfigController2 implements TextWatcher,
private String mUseSystemCertsString;
private String mTrustOnFirstUse;
private String mDoNotProvideEapUserCertString;
+ private String mDoNotValidateEapServerString;
@VisibleForTesting String mInstallCertsString;
private Spinner mSecuritySpinner;
@@ -287,6 +288,8 @@ public class WifiConfigController2 implements TextWatcher,
mTrustOnFirstUse = mContext.getString(R.string.wifi_trust_on_first_use);
mDoNotProvideEapUserCertString =
mContext.getString(R.string.wifi_do_not_provide_eap_user_cert);
+ mDoNotValidateEapServerString =
+ mContext.getString(R.string.wifi_do_not_validate_eap_server);
mInstallCertsString = mContext.getString(R.string.wifi_install_credentials);
if (Flags.androidVWifiApi() && mWifiEntrySecurity == WifiEntry.SECURITY_WEP) {
@@ -552,7 +555,8 @@ public class WifiConfigController2 implements TextWatcher,
// Disallow submit if the user has not selected a CA certificate for an EAP network
// configuration.
enabled = false;
- } else if (mEapDomainView != null
+ } else if (!caCertSelection.equals(mDoNotValidateEapServerString)
+ && mEapDomainView != null
&& mView.findViewById(R.id.l_domain).getVisibility() != View.GONE
&& TextUtils.isEmpty(mEapDomainView.getText().toString())) {
// Disallow submit if the user chooses to use a certificate for EAP server
@@ -574,6 +578,7 @@ public class WifiConfigController2 implements TextWatcher,
}
void showWarningMessagesIfAppropriate() {
+ mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.GONE);
mView.findViewById(R.id.no_user_cert_warning).setVisibility(View.GONE);
mView.findViewById(R.id.no_domain_warning).setVisibility(View.GONE);
mView.findViewById(R.id.ssid_too_long_warning).setVisibility(View.GONE);
@@ -586,7 +591,13 @@ public class WifiConfigController2 implements TextWatcher,
}
if (mEapCaCertSpinner != null
&& mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
- if (mEapDomainView != null
+ String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
+ if (caCertSelection.equals(mDoNotValidateEapServerString)) {
+ // Display warning if user chooses not to validate the EAP server with a
+ // user-supplied CA certificate in an EAP network configuration.
+ mView.findViewById(R.id.no_ca_cert_warning).setVisibility(View.VISIBLE);
+ } else if (!caCertSelection.equals(mUnspecifiedCertString)
+ && mEapDomainView != null
&& mView.findViewById(R.id.l_domain).getVisibility() != View.GONE
&& TextUtils.isEmpty(mEapDomainView.getText().toString())) {
// Display warning if user chooses to use a certificate without restricting the
@@ -743,7 +754,8 @@ public class WifiConfigController2 implements TextWatcher,
config.enterpriseConfig.setCaCertificateAliases(null);
config.enterpriseConfig.setCaPath(null);
config.enterpriseConfig.setDomainSuffixMatch(mEapDomainView.getText().toString());
- if (caCert.equals(mUnspecifiedCertString)) {
+ if (caCert.equals(mUnspecifiedCertString)
+ || caCert.equals(mDoNotValidateEapServerString)) {
// ca_cert already set to null, so do nothing.
} else if (mIsTrustOnFirstUseSupported && caCert.equals(mTrustOnFirstUse)) {
config.enterpriseConfig.enableTrustOnFirstUse(true);
@@ -778,7 +790,8 @@ public class WifiConfigController2 implements TextWatcher,
}
// Only set certificate option if there is a valid CA certificate.
- if (caCert.equals(mUnspecifiedCertString)) {
+ if (caCert.equals(mUnspecifiedCertString)
+ || caCert.equals(mDoNotValidateEapServerString)) {
config.enterpriseConfig.setOcsp(WifiEnterpriseConfig.OCSP_NONE);
config.enterpriseConfig.setMinimumTlsVersion(WifiEnterpriseConfig.TLS_V1_0);
} else {
@@ -1086,7 +1099,7 @@ public class WifiConfigController2 implements TextWatcher,
loadCertificates(
mEapCaCertSpinner,
mAndroidKeystoreAliasLoader.getCaCertAliases(),
- null /* noCertificateString */,
+ mDoNotValidateEapServerString /* noCertificateString */,
false /* showMultipleCerts */,
true /* showUsePreinstalledCertOption */);
loadCertificates(
@@ -1170,7 +1183,7 @@ public class WifiConfigController2 implements TextWatcher,
&& enterpriseConfig.isTrustOnFirstUseEnabled()) {
setSelection(mEapCaCertSpinner, mTrustOnFirstUse);
} else {
- setSelection(mEapCaCertSpinner, mUnspecifiedCertString);
+ setSelection(mEapCaCertSpinner, mDoNotValidateEapServerString);
}
} else if (caCerts.length == 1) {
setSelection(mEapCaCertSpinner, caCerts[0]);
@@ -1179,7 +1192,7 @@ public class WifiConfigController2 implements TextWatcher,
loadCertificates(
mEapCaCertSpinner,
mAndroidKeystoreAliasLoader.getCaCertAliases(),
- null /* noCertificateString */,
+ mDoNotValidateEapServerString /* noCertificateString */,
true /* showMultipleCerts */,
true /* showUsePreinstalledCertOption */);
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
@@ -1321,7 +1334,8 @@ public class WifiConfigController2 implements TextWatcher,
String eapCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
if (eapCertSelection.equals(mUnspecifiedCertString)
|| (mIsTrustOnFirstUseSupported
- && eapCertSelection.equals(mTrustOnFirstUse))) {
+ && eapCertSelection.equals(mTrustOnFirstUse))
+ || eapCertSelection.equals(mUnspecifiedCertString)) {
setMinTlsVerInvisible();
// Domain suffix matching is not relevant if the user hasn't chosen a CA
// certificate yet, or chooses not to validate the EAP server.
@@ -1595,8 +1609,7 @@ public class WifiConfigController2 implements TextWatcher,
}).collect(Collectors.toList()));
}
- if (!TextUtils.isEmpty(noCertificateString)
- && mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
+ if (mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
certs.add(noCertificateString);
}
--
2.34.1