Merge "Use installed keystore alias to check if enterprise config is insure" into rvc-dev

This commit is contained in:
Nate Jiang
2020-06-20 00:01:11 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 3 deletions

View File

@@ -1425,10 +1425,19 @@ public class WifiEnterpriseConfig implements Parcelable {
if (mEapMethod != Eap.PEAP && mEapMethod != Eap.TLS && mEapMethod != Eap.TTLS) { if (mEapMethod != Eap.PEAP && mEapMethod != Eap.TLS && mEapMethod != Eap.TTLS) {
return false; return false;
} }
if (!mIsAppInstalledCaCert && TextUtils.isEmpty(getCaPath())) { if (TextUtils.isEmpty(getAltSubjectMatch())
&& TextUtils.isEmpty(getDomainSuffixMatch())) {
// Both subject and domain match are not set, it's insecure.
return true; return true;
} }
return TextUtils.isEmpty(getAltSubjectMatch()) && TextUtils.isEmpty( if (mIsAppInstalledCaCert) {
getDomainSuffixMatch()); // CA certificate is installed by App, it's secure.
return false;
}
if (getCaCertificateAliases() != null) {
// CA certificate alias from keyStore is set, it's secure.
return false;
}
return TextUtils.isEmpty(getCaPath());
} }
} }

View File

@@ -565,6 +565,13 @@ public class WifiEnterpriseConfigTest {
secureConfig.setCaCertificate(FakeKeys.CA_CERT0); secureConfig.setCaCertificate(FakeKeys.CA_CERT0);
secureConfig.setDomainSuffixMatch(TEST_DOMAIN_SUFFIX_MATCH); secureConfig.setDomainSuffixMatch(TEST_DOMAIN_SUFFIX_MATCH);
assertFalse(secureConfig.isInsecure()); assertFalse(secureConfig.isInsecure());
WifiEnterpriseConfig secureConfigWithCaAlias = new WifiEnterpriseConfig();
secureConfigWithCaAlias.setEapMethod(Eap.PEAP);
secureConfigWithCaAlias.setPhase2Method(Phase2.MSCHAPV2);
secureConfigWithCaAlias.setCaCertificateAliases(new String[]{"alias1", "alisa2"});
secureConfigWithCaAlias.setDomainSuffixMatch(TEST_DOMAIN_SUFFIX_MATCH);
assertFalse(secureConfigWithCaAlias.isInsecure());
} }
} }