From 6b93c97a5e910c918108044afe6cbe922f5a8fab Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 14 Aug 2019 14:55:08 +0200 Subject: [PATCH] Use certifi for uploading crash reports CURA-6698 --- cura/CrashHandler.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cura/CrashHandler.py b/cura/CrashHandler.py index 6e6da99b0f..1d85a1da54 100644 --- a/cura/CrashHandler.py +++ b/cura/CrashHandler.py @@ -12,9 +12,10 @@ import json import ssl import urllib.request import urllib.error -import shutil -from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, Qt, QUrl +import certifi + +from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, QUrl from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QTextEdit, QGroupBox, QCheckBox, QPushButton from PyQt5.QtGui import QDesktopServices @@ -22,7 +23,6 @@ from UM.Application import Application from UM.Logger import Logger from UM.View.GL.OpenGL import OpenGL from UM.i18n import i18nCatalog -from UM.Platform import Platform from UM.Resources import Resources catalog = i18nCatalog("cura") @@ -352,11 +352,13 @@ class CrashHandler: # Convert data to bytes binary_data = json.dumps(self.data).encode("utf-8") + # 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()) # Submit data - kwoptions = {"data": binary_data, "timeout": 5} - - if Platform.isOSX(): - kwoptions["context"] = ssl._create_unverified_context() + kwoptions = {"data": binary_data, + "timeout": 5, + "context": context} Logger.log("i", "Sending crash report info to [%s]...", self.crash_url) if not self.has_started: