summaryrefslogtreecommitdiff
path: root/app/src/main/java/se
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2019-05-20 23:58:26 +0200
committercyBerta <cyberta@riseup.net>2019-05-20 23:59:09 +0200
commit5fd9cd738f26797cf16576bf4011852c9f3052a8 (patch)
tree06161d9b2af8c7679596ecea32ec5af4e2d7a761 /app/src/main/java/se
parentdf991bb8a28ec8dd42d3ffcdcdc6cc0a6d1ce915 (diff)
improve provider json validation during setup
Diffstat (limited to 'app/src/main/java/se')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
index 78ded399..5cf27854 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
@@ -54,7 +54,6 @@ import okhttp3.OkHttpClient;
import se.leap.bitmaskclient.Constants.CREDENTIAL_ERRORS;
import se.leap.bitmaskclient.utils.ConfigHelper;
-import static se.leap.bitmaskclient.utils.ConfigHelper.getFingerprintFromCertificate;
import static se.leap.bitmaskclient.Constants.BROADCAST_PROVIDER_API_EVENT;
import static se.leap.bitmaskclient.Constants.BROADCAST_RESULT_CODE;
import static se.leap.bitmaskclient.Constants.BROADCAST_RESULT_KEY;
@@ -107,6 +106,7 @@ import static se.leap.bitmaskclient.R.string.vpn_certificate_is_invalid;
import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_cert;
import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_details;
import static se.leap.bitmaskclient.R.string.warning_expired_provider_cert;
+import static se.leap.bitmaskclient.utils.ConfigHelper.getFingerprintFromCertificate;
import static se.leap.bitmaskclient.utils.ConfigHelper.parseRsaKeyFromString;
import static se.leap.bitmaskclient.utils.PreferenceHelper.deleteProviderDetailsFromPreferences;
import static se.leap.bitmaskclient.utils.PreferenceHelper.getFromPersistedProvider;
@@ -271,9 +271,6 @@ public abstract class ProviderApiManagerBase {
}
}
-
-
-
private Bundle tryToRegister(Provider provider, Bundle task) {
Bundle result = new Bundle();
@@ -697,7 +694,14 @@ public abstract class ProviderApiManagerBase {
}
Bundle validateProviderDetails(Provider provider) {
- Bundle result = validateCertificateForProvider(provider);
+ Bundle result = new Bundle();
+ result.putBoolean(BROADCAST_RESULT_KEY, false);
+
+ if (!provider.hasDefinition()) {
+ return result;
+ }
+
+ result = validateCertificateForProvider(result, provider);
//invalid certificate or no certificate
if (result.containsKey(ERRORS) || (result.containsKey(BROADCAST_RESULT_KEY) && !result.getBoolean(BROADCAST_RESULT_KEY)) ) {
@@ -709,10 +713,7 @@ public abstract class ProviderApiManagerBase {
return result;
}
- protected Bundle validateCertificateForProvider(Provider provider) {
- Bundle result = new Bundle();
- result.putBoolean(BROADCAST_RESULT_KEY, false);
-
+ protected Bundle validateCertificateForProvider(Bundle result, Provider provider) {
String caCert = provider.getCaCert();
if (ConfigHelper.checkErroneousDownload(caCert)) {