summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-12-22 11:23:13 +0100
committerParménides GV <parmegv@sdf.org>2014-12-22 11:23:13 +0100
commit410bafed7c5d31128a4957a7697d0e34989f4390 (patch)
tree3441a35c6439f96ad8eee7f8d4fb24d2a9a99193 /app
parent7acd42f94f0161992d48ab4533ad6283df4e94e3 (diff)
parente4b49fb3cfb1e69cc4617bfcc5b20cbc22df4f8c (diff)
Merge branch 'bug/NullPointer-in-validCertificate-#6582' into develop
Diffstat (limited to 'app')
-rw-r--r--app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java21
-rw-r--r--app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java22
2 files changed, 25 insertions, 18 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
index 886d70a0..ce13d322 100644
--- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -554,15 +554,18 @@ public class ProviderAPI extends IntentService {
if(!ConfigHelper.checkErroneousDownload(cert_string)) {
X509Certificate certificate = ConfigHelper.parseX509CertificateFromString(cert_string);
try {
- JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
- String fingerprint = provider_json.getString(Provider.CA_CERT_FINGERPRINT);
- String encoding = fingerprint.split(":")[0];
- String expected_fingerprint = fingerprint.split(":")[1];
- String real_fingerprint = base64toHex(Base64.encodeToString(
- MessageDigest.getInstance(encoding).digest(certificate.getEncoded()),
- Base64.DEFAULT));
-
- result = real_fingerprint.trim().equalsIgnoreCase(expected_fingerprint.trim());
+ if(certificate != null) {
+ JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
+ String fingerprint = provider_json.getString(Provider.CA_CERT_FINGERPRINT);
+ String encoding = fingerprint.split(":")[0];
+ String expected_fingerprint = fingerprint.split(":")[1];
+ String real_fingerprint = base64toHex(Base64.encodeToString(
+ MessageDigest.getInstance(encoding).digest(certificate.getEncoded()),
+ Base64.DEFAULT));
+
+ result = real_fingerprint.trim().equalsIgnoreCase(expected_fingerprint.trim());
+ } else
+ result = false;
} catch (JSONException e) {
result = false;
} catch (NoSuchAlgorithmException e) {
diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
index 9d0b4db6..8b8cabdf 100644
--- a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -547,15 +547,19 @@ public class ProviderAPI extends IntentService {
if(!ConfigHelper.checkErroneousDownload(cert_string)) {
X509Certificate certificate = ConfigHelper.parseX509CertificateFromString(cert_string);
try {
- JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
- String fingerprint = provider_json.getString(Provider.CA_CERT_FINGERPRINT);
- String encoding = fingerprint.split(":")[0];
- String expected_fingerprint = fingerprint.split(":")[1];
- String real_fingerprint = base64toHex(Base64.encodeToString(
- MessageDigest.getInstance(encoding).digest(certificate.getEncoded()),
- Base64.DEFAULT));
-
- result = real_fingerprint.trim().equalsIgnoreCase(expected_fingerprint.trim());
+ if(certificate != null) {
+ JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
+ String fingerprint = provider_json.getString(Provider.CA_CERT_FINGERPRINT);
+ String encoding = fingerprint.split(":")[0];
+ String expected_fingerprint = fingerprint.split(":")[1];
+ String real_fingerprint = base64toHex(Base64.encodeToString(
+ MessageDigest.getInstance(encoding).digest(certificate.getEncoded()),
+ Base64.DEFAULT));
+
+ result = real_fingerprint.trim().equalsIgnoreCase(expected_fingerprint.trim());
+ }
+ else
+ result = false;
} catch (JSONException e) {
result = false;
} catch (NoSuchAlgorithmException e) {