mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-11 17:59:00 +08:00
Use certifi for firmware update checker
CURA-6698
This commit is contained in:
parent
6b93c97a5e
commit
a2dcbc3be7
@ -10,6 +10,9 @@ from UM.Version import Version
|
||||
import urllib.request
|
||||
from urllib.error import URLError
|
||||
from typing import Dict, Optional
|
||||
import ssl
|
||||
|
||||
import certifi
|
||||
|
||||
from .FirmwareUpdateCheckerLookup import FirmwareUpdateCheckerLookup, getSettingsKeyForMachine
|
||||
from .FirmwareUpdateCheckerMessage import FirmwareUpdateCheckerMessage
|
||||
@ -39,8 +42,12 @@ class FirmwareUpdateCheckerJob(Job):
|
||||
result = self.STRING_ZERO_VERSION
|
||||
|
||||
try:
|
||||
# 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())
|
||||
|
||||
request = urllib.request.Request(url, headers = self._headers)
|
||||
response = urllib.request.urlopen(request)
|
||||
response = urllib.request.urlopen(request, context = context)
|
||||
result = response.read().decode("utf-8")
|
||||
except URLError:
|
||||
Logger.log("w", "Could not reach '{0}', if this URL is old, consider removal.".format(url))
|
||||
|
Loading…
x
Reference in New Issue
Block a user