From 301adeab4b1630645e53baa982b35cba394e52b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 17 Nov 2014 18:44:36 +0100 Subject: Update vpn certificate and store it correctly. One more onReceiveResult for Dashboard, that method needs a rethink: a statemachine class, and a simple "next()" method? The reality is that the onReceiveResult specifies a linked process, and that should have a better model than a series of if/else cases with strings comparisons hehehe --- .../release/java/se/leap/bitmaskclient/ProviderAPI.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'app/src/release/java/se/leap/bitmaskclient') diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java index e2da588c..0fa60550 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java @@ -845,23 +845,13 @@ public class ProviderAPI extends IntentService { } return true; } - - private boolean updateVpnCertificate() { - getNewCert(); - - Intent updateEIP = new Intent(getApplicationContext(), EIP.class); - updateEIP.setAction(Constants.ACTION_UPDATE_EIP_SERVICE); - startService(updateEIP); - - return true; - } /** * Downloads a new OpenVPN certificate, attaching authenticated cookie for authenticated certificate. * * @return true if certificate was downloaded correctly, false if provider.json is not present in SharedPreferences, or if the certificate url could not be parsed as a URI, or if there was an SSL error. */ - private boolean getNewCert() { + private boolean updateVpnCertificate() { try { JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); @@ -898,6 +888,7 @@ public class ProviderAPI extends IntentService { certificateString = certAndKey[i++] + certAndKey[i]; } } + RSAPrivateKey key = ConfigHelper.parseRsaKeyFromString(keyString); keyString = Base64.encodeToString(key.getEncoded(), Base64.DEFAULT); preferences.edit().putString(Constants.PRIVATE_KEY, "-----BEGIN RSA PRIVATE KEY-----\n"+keyString+"-----END RSA PRIVATE KEY-----").commit(); @@ -905,7 +896,6 @@ public class ProviderAPI extends IntentService { X509Certificate certificate = ConfigHelper.parseX509CertificateFromString(certificateString); certificateString = Base64.encodeToString(certificate.getEncoded(), Base64.DEFAULT); preferences.edit().putString(Constants.CERTIFICATE, "-----BEGIN CERTIFICATE-----\n"+certificateString+"-----END CERTIFICATE-----").commit(); - preferences.edit().putString(Constants.DATE_FROM_CERTIFICATE, EIP.certificate_date_format.format(Calendar.getInstance().getTime())).commit(); return true; } catch (CertificateException e) { // TODO Auto-generated catch block -- cgit v1.2.3