Skip to content

The only downloader you need. 下载器的集大成者。

feat(download): 添加 SSL 证书验证选项

XiaoYouChRba99b883db34
diff --git a/app/common/config.py b/app/common/config.py
index 38952508..60cf4770 100644
--- a/app/common/config.py
+++ b/app/common/config.py
@@ -59,6 +59,7 @@ class Config(QConfig):
maxTaskNum = RangeConfigItem("Download", "MaxTaskNum", 3, RangeValidator(1, 10))
speedLimitation = RangeConfigItem("Download", "SpeedLimitation", 0, RangeValidator(0, 104857600)) # 单位 KB
autoSpeedUp = ConfigItem("Download", "AutoSpeedUp", True, BoolValidator())
+ SSLVerify = ConfigItem("Download", "SSLVerify", True, BoolValidator(), restart=True)
proxyServer = ConfigItem("Download", "ProxyServer", "Auto", ProxyValidator())
# browser
diff --git a/app/common/download_task.py b/app/common/download_task.py
index ab9bba38..94ed9a4a 100644
--- a/app/common/download_task.py
+++ b/app/common/download_task.py
@@ -55,7 +55,7 @@ class DownloadTask(QThread):
self.tasks: list[Task] = []
self.historySpeed = [0] * 10 # 历史速度 10 秒内的平均速度
- self.client = httpx.AsyncClient(headers=headers, verify=False,
+ self.client = httpx.AsyncClient(headers=headers, verify=cfg.SSLVerify.value,
proxy=getProxy(), limits=httpx.Limits(max_connections=256))
self.__initThread = Thread(target=self.__initTask, daemon=True) # TODO 获取文件名和文件大小的线程等信息, 暂时使用线程方式
diff --git a/app/common/methods.py b/app/common/methods.py
index 2e2ddfb0..c760e744 100644
--- a/app/common/methods.py
+++ b/app/common/methods.py
@@ -188,7 +188,7 @@ def getLocalTimeFromGithubApiTime(gmtTimeStr:str):
return localTimeNaive
-def getLinkInfo(url: str, headers: dict, fileName: str = "", verify: bool = False, proxy: str = "", followRedirects: bool = True) -> tuple:
+def getLinkInfo(url: str, headers: dict, fileName: str = "", verify: bool = cfg.SSLVerify.value, proxy: str = "", followRedirects: bool = True) -> tuple:
if not proxy:
proxy = getProxy()
headers = headers.copy()
diff --git a/app/view/setting_interface.py b/app/view/setting_interface.py
index 77fb52f8..c608bbcb 100644
--- a/app/view/setting_interface.py
+++ b/app/view/setting_interface.py
@@ -252,6 +252,15 @@ class SettingInterface(SmoothScrollArea):
cfg.autoSpeedUp,
self.downloadGroup
)
+
+ self.SSLVerifyCard = SwitchSettingCard(
+ FIF.DEVELOPER_TOOLS,
+ "下载时验证 SSL 证书",
+ "文件无法下载时,可尝试关闭该选项",
+ cfg.SSLVerify,
+ self.downloadGroup
+ )
+
self.downloadFolderCard = SelectFolderSettingCard(
cfg.downloadFolder,
cfg.historyDownloadFolder,
@@ -428,6 +437,7 @@ class SettingInterface(SmoothScrollArea):
self.downloadGroup.addSettingCard(self.maxTaskNumCard)
self.downloadGroup.addSettingCard(self.speedLimitationCard)
self.downloadGroup.addSettingCard(self.autoSpeedUpCard)
+ self.downloadGroup.addSettingCard(self.SSLVerifyCard)
self.downloadGroup.addSettingCard(self.downloadFolderCard)
self.downloadGroup.addSettingCard(self.proxyServerCard)