diff options
Diffstat (limited to 'service')
-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) |