Skip to content

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

fix(security): HTTP 与 FTPS 用 certifi 根证书验证 TLS,不再信任 eMudhra 泄露的中间证书

XiaoYouChRf1ac106f0cd2
diff --git a/app/client.py b/app/client.py
index f31ab1cc..150688b1 100644
--- a/app/client.py
+++ b/app/client.py
@@ -6,6 +6,7 @@ from datetime import timedelta
from pathlib import Path
from typing import TYPE_CHECKING
+import certifi
from loguru import logger
from wreq import Client, Emulation, Proxy
from wreq.dns import DnsOptions
@@ -104,7 +105,11 @@ def buildClient(
readTimeout: int | None = None,
) -> Client:
resolved = toEmulation("") if emulation is ... else emulation
- config: ClientConfig = {"tls_verify": cfg.shouldVerifySsl.value, "redirect": Policy.limited(10)}
+ # wreq 内置的根证书跟着 wreq 发版才更新,eMudhra 私钥泄露(2026-10)时还信任被吊销的中间证书
+ config: ClientConfig = {
+ "tls_verify": Path(certifi.where()) if cfg.shouldVerifySsl.value else False,
+ "redirect": Policy.limited(10),
+ }
if cfg.shouldUseSystemDns.value:
config["dns_options"] = DnsOptions(system_dns=True)
diff --git a/features/ftp_pack/task.py b/features/ftp_pack/task.py
index 8f263602..9ac96780 100644
--- a/features/ftp_pack/task.py
+++ b/features/ftp_pack/task.py
@@ -11,6 +11,7 @@ from struct import pack, unpack
from urllib.parse import unquote, urlparse
import aioftp
+import certifi
from loguru import logger
from app.config.cfg import cfg
@@ -72,7 +73,7 @@ class FtpConnectionInfo:
lastError: Exception | None = None
for index, (port, mode) in enumerate(attempts):
if mode != "plain":
- sslCtx = ssl.create_default_context()
+ sslCtx = ssl.create_default_context(cafile=certifi.where())
if not cfg.shouldVerifySsl.value:
sslCtx.check_hostname = False
sslCtx.verify_mode = ssl.CERT_NONE
diff --git a/pyproject.toml b/pyproject.toml
index 75621fab..0fd13446 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,6 +21,7 @@ dependencies = [
"uvloop>=0.22.1; sys_platform != 'win32'",
"pyobjc-framework-Cocoa>=10.0; sys_platform == 'darwin'",
"pyobjc-framework-Quartz>=10.0; sys_platform == 'darwin'",
+ "certifi>=2026.10.19",
]
[dependency-groups]
diff --git a/uv.lock b/uv.lock
index 34b9f6da..a4f1dbf7 100644
--- a/uv.lock
+++ b/uv.lock
@@ -209,6 +209,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/f5/10/56978295c14794b2c12007b07f3e41ba26acda9257457d7085b0bb3bb90c/brotli-1.2.0-cp314-cp314-win_amd64.whl", hash = "sha256:e7c0af964e0b4e3412a0ebf341ea26ec767fa0b4cf81abb5e897c9338b5ad6a3", size = 375639, upload-time = "2025-11-05T18:38:55.67Z" },
]
+[[package]]
+name = "certifi"
+version = "2026.10.19"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/a6/bd/1436c50cc46699de0230fbaacc1d1de7bfec413176099949e9d5112e88f2/certifi-2026.10.19.tar.gz", hash = "sha256:035c1e85572b141bf1c3a3eff0e33a8eb74917522f2559075ff8d2fea780a1ae", size = 137598, upload-time = "2026-10-20T02:24:16.604Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/c4/51/29046e48f693c54e5b7412216d447a1d8362c9653148d98c02cdf65fa733/certifi-2026.10.19-py3-none-any.whl", hash = "sha256:42d35340cc5b9ba78e818ddbff0c5b1c2b779de448a340fd1b989f5fa8670e1b", size = 136464, upload-time = "2026-10-20T02:24:15.072Z" },
+]
+
[[package]]
name = "colorama"
version = "0.4.6"
@@ -366,6 +375,7 @@ version = "4.3.5"
source = { virtual = "." }
dependencies = [
{ name = "aioftp", extra = ["socks"] },
+ { name = "certifi" },
{ name = "desktop-notifier" },
{ name = "libtorrent" },
{ name = "loguru" },
@@ -397,6 +407,7 @@ dev = [
[package.metadata]
requires-dist = [
{ name = "aioftp", extras = ["socks"], specifier = ">=0.27.2" },
+ { name = "certifi", specifier = ">=2026.10.19" },
{ name = "desktop-notifier", specifier = ">=6.2.0" },
{ name = "libtorrent", specifier = ">=2.0.13" },
{ name = "loguru", specifier = ">=0.7.3" },