summaryrefslogtreecommitdiff
path: root/app/src/production/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2017-11-03 15:17:45 +0100
committercyBerta <cyberta@riseup.net>2017-11-03 15:17:45 +0100
commit859c2b4496618c8142c70610ebba395e9aa4d5dc (patch)
tree137fd4af0292e8b8a8abb26307f82c580f485a0f /app/src/production/java
parent719c63ee33a88b239e96efead8da14cf985ca9aa (diff)
#8778 fixes invalid provider error handling
Diffstat (limited to 'app/src/production/java')
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java
index 982080de..70a2c27c 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -107,6 +107,12 @@ public class ProviderAPI extends ProviderApiBase {
else
provider_dot_json_string = downloadWithCommercialCA(provider_main_url + "/provider.json", provider_ca_cert_fingerprint);
+ if (!isValidJson(provider_dot_json_string)) {
+ result.putString(ERRORS, getString(malformed_url));
+ result.putBoolean(RESULT_KEY, false);
+ return result;
+ }
+
try {
JSONObject provider_json = new JSONObject(provider_dot_json_string);
provider_api_url = provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION);
@@ -147,7 +153,7 @@ public class ProviderAPI extends ProviderApiBase {
preferences.edit().putString(Constants.KEY, eip_service_json.toString()).commit();
result.putBoolean(RESULT_KEY, true);
- } catch (JSONException e) {
+ } catch (NullPointerException | JSONException e) {
String reason_to_fail = pickErrorMessage(eip_service_json_string);
result.putString(ERRORS, reason_to_fail);
result.putBoolean(RESULT_KEY, false);
@@ -171,7 +177,7 @@ public class ProviderAPI extends ProviderApiBase {
String cert_string = downloadWithProviderCA(new_cert_string_url.toString());
- if (cert_string.isEmpty() || ConfigHelper.checkErroneousDownload(cert_string))
+ if (cert_string == null || cert_string.isEmpty() || ConfigHelper.checkErroneousDownload(cert_string))
return false;
else
return loadCertificate(cert_string);
@@ -253,7 +259,7 @@ public class ProviderAPI extends ProviderApiBase {
responseString = sendGetStringToServer(string_url, headerArgs, okHttpClient);
- if (responseString.contains(ERRORS)) {
+ if (responseString != null && responseString.contains(ERRORS)) {
try {
// try to download with provider CA on certificate error
JSONObject responseErrorJson = new JSONObject(responseString);