diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java | 10 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java | 4 |
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; |