diff options
author | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-08-30 16:58:33 -0300 |
---|---|---|
committer | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-08-30 17:04:45 -0300 |
commit | b1fe205ebb5248104b365f372a72659b2471812e (patch) | |
tree | a89e9f6ca60d401038abe9f7b37c1d10d6e7c659 | |
parent | 86db68912fc1fb0d1253a6a4b18a6f481756bc4d (diff) |
[#765] Move combined certificates to the leap folder
Since we are creating the combined certificates at the beginning
of the UA and using it for multiple users, it makes more sense to
create it in the leap folder instead of on a temporary file
This bundle will be updated on every UA start
-rw-r--r-- | service/pixelated/bitmask_libraries/keymanager.py | 2 | ||||
-rw-r--r-- | service/pixelated/bitmask_libraries/provider.py | 10 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/test_keymanager.py | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/service/pixelated/bitmask_libraries/keymanager.py b/service/pixelated/bitmask_libraries/keymanager.py index 46125a6c..f73daee4 100644 --- a/service/pixelated/bitmask_libraries/keymanager.py +++ b/service/pixelated/bitmask_libraries/keymanager.py @@ -31,7 +31,7 @@ class Keymanager(object): token=token, ca_cert_path=provider.provider_api_cert, api_uri=provider.api_uri, api_version=provider.api_version, uid=uuid, gpgbinary=leap_config.gpg_binary, - combined_ca_bundle=provider.combined_ca_bundle) + combined_ca_bundle=provider.combined_cerfificates_path) @defer.inlineCallbacks def generate_openpgp_key(self): diff --git a/service/pixelated/bitmask_libraries/provider.py b/service/pixelated/bitmask_libraries/provider.py index 97becac8..96935fbc 100644 --- a/service/pixelated/bitmask_libraries/provider.py +++ b/service/pixelated/bitmask_libraries/provider.py @@ -39,6 +39,10 @@ class LeapProvider(object): return str(os.path.join(leap_config.leap_home, 'providers', self.server_name, 'keys', 'client', 'api.pem')) @property + def combined_cerfificates_path(self): + return str(os.path.join(leap_config.leap_home, 'providers', self.server_name, 'keys', 'client', 'ca_bundle')) + + @property def api_uri(self): return self.provider_json.get('api_uri') @@ -182,16 +186,12 @@ class LeapProvider(object): elif not self.provider_api_cert: return leap_ca_bundle - tmp_file = tempfile.NamedTemporaryFile(delete=False) - - with open(tmp_file.name, 'w') as fout: + with open(self.combined_cerfificates_path, 'w') as fout: fin = fileinput.input(files=(leap_ca_bundle, self.provider_api_cert)) for line in fin: fout.write(line) fin.close() - self.combined_ca_bundle = tmp_file.name - def setup_ca_bundle(self): path = os.path.join(leap_config.leap_home, 'providers', self.server_name, 'keys', 'client') if not os.path.isdir(path): diff --git a/service/test/unit/bitmask_libraries/test_keymanager.py b/service/test/unit/bitmask_libraries/test_keymanager.py index 2d20e971..cdd6f3de 100644 --- a/service/test/unit/bitmask_libraries/test_keymanager.py +++ b/service/test/unit/bitmask_libraries/test_keymanager.py @@ -27,7 +27,7 @@ class KeymanagerTest(AbstractLeapTest): @patch('pixelated.bitmask_libraries.keymanager.KeyManager') def test_that_keymanager_is_created(self, keymanager_mock): when(self.provider)._discover_nicknym_server().thenReturn('https://nicknym.some-server.test:6425/') - self.provider.combined_ca_bundle = 'combined_ca_bundle' + self.provider.combined_cerfificates_path = 'combined_cerfificates_path' self.provider.provider_api_cert = '/some/path/to/provider_ca_cert' leap_config.gpg_binary = '/path/to/gpg' @@ -47,7 +47,7 @@ class KeymanagerTest(AbstractLeapTest): api_version='1', uid=self.auth.uuid, gpgbinary='/path/to/gpg', - combined_ca_bundle='combined_ca_bundle') + combined_ca_bundle='combined_cerfificates_path') @patch('pixelated.bitmask_libraries.keymanager.KeyManager') def test_gen_key(self, keymanager_mock): |