summaryrefslogtreecommitdiff
path: root/service/pixelated/bitmask_libraries/provider.py
diff options
context:
space:
mode:
authorJefferson Stachelski <jstachel@thoughtworks.com>2016-01-22 19:49:16 -0200
committerJefferson Stachelski <jstachel@thoughtworks.com>2016-01-22 19:49:16 -0200
commitfd7f55a40ba1c5b32dd22e7856c37484f81d8789 (patch)
tree1ff21feecce3ac7c11ecd464ffccd6269a479f2a /service/pixelated/bitmask_libraries/provider.py
parent18123f6745beaba99b40a4db6d9aad1dbcdf6925 (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
Diffstat (limited to 'service/pixelated/bitmask_libraries/provider.py')
-rw-r--r--service/pixelated/bitmask_libraries/provider.py11
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)