summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/ProviderAPI.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap/leapclient/ProviderAPI.java')
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index 00d7d820..72cc9b62 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -584,8 +584,18 @@ public class ProviderAPI extends IntentService {
boolean danger_on = ConfigHelper.getBoolFromSharedPref(ConfigHelper.DANGER_ON);
String cert_string = getStringFromProvider(new_cert_string_url, danger_on);
- if(!cert_string.isEmpty()) {
- ConfigHelper.saveSharedPref(ConfigHelper.CERT_KEY, cert_string);
+ if(!cert_string.isEmpty()) {
+ // API returns concatenated cert & key. Split them for OpenVPN options
+ String certificate = null, key = null;
+ String[] certAndKey = cert_string.split("(?<=-\n)");
+ for (int i=0; i < certAndKey.length-1; i++){
+ if ( certAndKey[i].contains("KEY") )
+ key = certAndKey[i++] + certAndKey[i];
+ else if ( certAndKey[i].contains("CERTIFICATE") )
+ certificate = certAndKey[i++] + certAndKey[i];
+ }
+ ConfigHelper.saveSharedPref(ConfigHelper.CERT_KEY, certificate);
+ ConfigHelper.saveSharedPref(ConfigHelper.KEY_KEY, key);
return true;
} else {
return false;