diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2019-08-13 13:59:25 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2019-08-13 13:59:27 +0300 |
commit | 2ed5fd73bc97738e4eb74ff3ef976f7dcb4c20b6 (patch) | |
tree | 1825e82676a23b697bd49c545f70341609100d18 /plugins/SliceInfoPlugin | |
parent | 445fb59c120de6d2d7e30da1c542c6c1a7573102 (diff) |
Use certifi CA certs with urllib requests
CURA-6698
Diffstat (limited to 'plugins/SliceInfoPlugin')
-rw-r--r-- | plugins/SliceInfoPlugin/SliceInfoJob.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/plugins/SliceInfoPlugin/SliceInfoJob.py b/plugins/SliceInfoPlugin/SliceInfoJob.py index a5667c1c13..50d6b560f1 100644 --- a/plugins/SliceInfoPlugin/SliceInfoJob.py +++ b/plugins/SliceInfoPlugin/SliceInfoJob.py @@ -8,6 +8,8 @@ import ssl import urllib.request import urllib.error +import certifi + class SliceInfoJob(Job): def __init__(self, url, data): @@ -20,11 +22,14 @@ class SliceInfoJob(Job): Logger.log("e", "URL or DATA for sending slice info was not set!") return - # Submit data - kwoptions = {"data" : self._data, "timeout" : 5} + # CURA-6698 Create an SSL context and use certifi CA certificates for verification. + context = ssl.SSLContext(protocol = ssl.PROTOCOL_TLSv1_2) + context.load_verify_locations(cafile = certifi.where()) - if Platform.isOSX(): - kwoptions["context"] = ssl._create_unverified_context() + # Submit data + kwoptions = {"data": self._data, + "timeout": 5, + "context": context} Logger.log("i", "Sending anonymous slice info to [%s]...", self._url) @@ -35,4 +40,4 @@ class SliceInfoJob(Job): except urllib.error.HTTPError: Logger.logException("e", "An HTTP error occurred while trying to send slice information") except Exception: # We don't want any exception to cause problems - Logger.logException("e", "An exception occurred while trying to send slice information")
\ No newline at end of file + Logger.logException("e", "An exception occurred while trying to send slice information") |