diff options
author | Sean Leonard <meanderingcode@aetherislands.net> | 2013-06-09 04:09:03 -0600 |
---|---|---|
committer | Sean Leonard <meanderingcode@aetherislands.net> | 2013-06-20 18:40:45 -0600 |
commit | 33338d43e0e83329a7c46807e096b8148e19aff7 (patch) | |
tree | 62eb9c0de87a2ef9ff66f0b79909429019dd0aae /src/se/leap/leapclient/ProviderAPI.java | |
parent | 9a9823f7e5bf0e46e360ba327ac6514ecd4bb320 (diff) |
Quite basic staring and stopping of VPN
Diffstat (limited to 'src/se/leap/leapclient/ProviderAPI.java')
-rw-r--r-- | src/se/leap/leapclient/ProviderAPI.java | 14 |
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; |