diff --git a/client/__main__.py b/client/__main__.py index d5d5d31e..45d9eb5b 100644 --- a/client/__main__.py +++ b/client/__main__.py @@ -21,22 +21,28 @@ def patch_requests(): """ config.create_config_directory() ca_certs_file = config.CERT_FILE - ca_certs_contents = requests.__loader__.get_data('requests/cacert.pem') - - should_write_certs = True - - if os.path.isfile(ca_certs_file): - with open(ca_certs_file, 'rb') as f: - existing_certs = f.read() - if existing_certs != ca_certs_contents: - should_write_certs = True - print("Updating local SSL certificates") - else: - should_write_certs = False - - if should_write_certs: - with open(ca_certs_file, 'wb') as f: - f.write(ca_certs_contents) + ca_certs_contents = None + try: + ca_certs_contents = requests.__loader__.get_data('requests/cacert.pem') + except OSError: + # TODO(kavigupta) not sure why this is coming up??? + pass + + if ca_certs_contents is not None: + should_write_certs = True + + if os.path.isfile(ca_certs_file): + with open(ca_certs_file, 'rb') as f: + existing_certs = f.read() + if existing_certs != ca_certs_contents: + should_write_certs = True + print("Updating local SSL certificates") + else: + should_write_certs = False + + if should_write_certs: + with open(ca_certs_file, 'wb') as f: + f.write(ca_certs_contents) os.environ['REQUESTS_CA_BUNDLE'] = ca_certs_file diff --git a/client/utils/locking.py b/client/utils/locking.py index 03d75909..1ef9575e 100644 --- a/client/utils/locking.py +++ b/client/utils/locking.py @@ -4,4 +4,4 @@ def lock(key, text): """Locks the given text using the given key and returns the result""" - return hmac.new(key.encode('utf-8'), text.encode('utf-8')).hexdigest() \ No newline at end of file + return hmac.new(key.encode('utf-8'), text.encode('utf-8'), digestmod='md5').hexdigest() diff --git a/client/utils/storage.py b/client/utils/storage.py index cc9c7052..92dd71ee 100644 --- a/client/utils/storage.py +++ b/client/utils/storage.py @@ -26,7 +26,7 @@ def set_foreign_function_type(func, restype, argtypes): SECURITY_KEY = 'uMWm4sviPK3LyPzgWYFn'.encode('utf-8') def mac(value): - mac = hmac.new(SECURITY_KEY) + mac = hmac.new(SECURITY_KEY, digestmod='md5') mac.update(repr(value).encode('utf-8')) return mac.hexdigest() diff --git a/requirements.txt b/requirements.txt index 89b05b92..6517762f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # Client requests[security]==2.20.0 -coverage==3.7.1 +coverage==4.5.4 # Tests nose==1.3.3 diff --git a/setup.py b/setup.py index 33807631..1eb98760 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,6 @@ ], install_requires=[ 'requests==2.12.4', - 'coverage==3.7.1' + 'coverage==4.5.4' ], )