From fd7f55a40ba1c5b32dd22e7856c37484f81d8789 Mon Sep 17 00:00:00 2001 From: Jefferson Stachelski Date: Fri, 22 Jan 2016 19:49:16 -0200 Subject: 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 --- service/pixelated/bitmask_libraries/provider.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'service/pixelated/bitmask_libraries') 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) -- cgit v1.2.3