diff options
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java index ca76a799..d4a640bb 100644 --- a/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java +++ b/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java @@ -18,6 +18,7 @@ package se.leap.bitmaskclient.utils; import android.content.Context; import android.content.res.Resources; +import android.os.Build; import android.os.Looper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -117,7 +118,12 @@ public class ConfigHelper { public static RSAPrivateKey parseRsaKeyFromString(String rsaKeyString) { RSAPrivateKey key; try { - KeyFactory kf = KeyFactory.getInstance("RSA"); + KeyFactory kf; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { + kf = KeyFactory.getInstance("RSA", "BC"); + } else { + kf = KeyFactory.getInstance("RSA"); + } rsaKeyString = rsaKeyString.replaceFirst("-----BEGIN RSA PRIVATE KEY-----", "").replaceFirst("-----END RSA PRIVATE KEY-----", ""); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.decode(rsaKeyString)); key = (RSAPrivateKey) kf.generatePrivate(keySpec); @@ -132,6 +138,9 @@ public class ConfigHelper { } catch (NullPointerException e) { e.printStackTrace(); return null; + } catch (NoSuchProviderException e) { + e.printStackTrace(); + return null; } return key; |