diff options
author | Jefferson Stachelski <jstachel@thoughtworks.com> | 2016-01-22 19:49:16 -0200 |
---|---|---|
committer | Jefferson Stachelski <jstachel@thoughtworks.com> | 2016-01-22 19:49:16 -0200 |
commit | fd7f55a40ba1c5b32dd22e7856c37484f81d8789 (patch) | |
tree | 1ff21feecce3ac7c11ecd464ffccd6269a479f2a | |
parent | 18123f6745beaba99b40a4db6d9aad1dbcdf6925 (diff) |
Fixed bug when tries download cert
It was rising an error when UA tried donwload the certificate and the
directory that file will be create doesn't exist yet
-rw-r--r-- | service/pixelated/bitmask_libraries/provider.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/service/pixelated/bitmask_libraries/provider.py b/service/pixelated/bitmask_libraries/provider.py index 75dcd3ae..9c889287 100644 --- a/service/pixelated/bitmask_libraries/provider.py +++ b/service/pixelated/bitmask_libraries/provider.py @@ -69,10 +69,21 @@ class LeapProvider(object): Downloads the server certificate, validates it against the provided fingerprint and stores it to file """ path = filename or self.local_ca_crt + + directory = self._extract_directory(path) + if not os.path.exists(directory): + os.makedirs(directory) + cert = self.fetch_valid_certificate() with open(path, 'w') as out: out.write(cert) + def _extract_directory(self, path): + splited = path.split('/') + splited.pop(-1) + directory = '/'.join(splited) + return directory + def fetch_valid_certificate(self): cert = self._fetch_certificate() self.validate_certificate(cert) |