summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2017-11-06 01:17:57 +0100
committercyBerta <cyberta@riseup.net>2017-11-06 01:17:57 +0100
commitd94eabbc4919b8484262d31abc996376917d46d4 (patch)
treea4e756994a83fc662c2ef4fe913b80df60df272e /app/src/main
parent719c63ee33a88b239e96efead8da14cf985ca9aa (diff)
#8777 fixes NPEs and errorneous provider selection
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java10
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java4
2 files changed, 10 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
index 4929f040..232a00e9 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
@@ -99,13 +99,12 @@ public class ConfigHelper {
return (X509Certificate) certificate;
}
- protected static RSAPrivateKey parseRsaKeyFromString(String RsaKeyString) {
+ protected static RSAPrivateKey parseRsaKeyFromString(String rsaKeyString) {
RSAPrivateKey key = null;
try {
KeyFactory kf = KeyFactory.getInstance("RSA", "BC");
-
- RsaKeyString = RsaKeyString.replaceFirst("-----BEGIN RSA PRIVATE KEY-----", "").replaceFirst("-----END RSA PRIVATE KEY-----", "");
- PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.decode(RsaKeyString, Base64.DEFAULT));
+ rsaKeyString = rsaKeyString.replaceFirst("-----BEGIN RSA PRIVATE KEY-----", "").replaceFirst("-----END RSA PRIVATE KEY-----", "");
+ PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.decode(rsaKeyString, Base64.DEFAULT));
key = (RSAPrivateKey) kf.generatePrivate(keySpec);
} catch (InvalidKeySpecException e) {
// TODO Auto-generated catch block
@@ -119,6 +118,9 @@ public class ConfigHelper {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ return null;
}
return key;
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
index caa48231..15440330 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
@@ -788,6 +788,10 @@ public abstract class ProviderApiBase extends IntentService {
//FIXME: don't save private keys in shared preferences! use the keystore
protected boolean loadCertificate(String cert_string) {
+ if (cert_string == null) {
+ return false;
+ }
+
try {
// API returns concatenated cert & key. Split them for OpenVPN options
String certificateString = null, keyString = null;