From b42b3ca4d3e50fdc0dd87ab9ce96851f2f647471 Mon Sep 17 00:00:00 2001 From: lixiangwuxian Date: Thu, 10 Apr 2025 02:13:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=20DownloadFile=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=9A=84=20HTTP=20=E4=BC=A0=E8=BE=93?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E7=A6=81=E7=94=A8=20HTTP/2=20?= =?UTF-8?q?=E5=B9=B6=E5=A2=9E=E5=BC=BA=20TLS=20=E8=AF=81=E4=B9=A6=E9=AA=8C?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/url.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/util/url.go b/util/url.go index 01d96c1..adc35eb 100644 --- a/util/url.go +++ b/util/url.go @@ -74,19 +74,22 @@ func DownloadFile(urlStr string, dirPath string) (filepath string, err error) { // 创建基础传输配置 transport := &http.Transport{ - ForceAttemptHTTP2: true, + ForceAttemptHTTP2: false, // 服务器不支持HTTP/2 + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: false, // 启用证书验证 + MinVersion: tls.VersionTLS12, + MaxVersion: tls.VersionTLS12, + CipherSuites: []uint16{ + tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + }, + NextProtos: []string{"http/1.1"}, // 禁用ALPN协商 + }, } // 如果是腾讯的特定域名,使用特殊的TLS配置 if strings.HasSuffix(parsedURL.Host, ".qq.com.cn") { - transport.TLSClientConfig = &tls.Config{ - MinVersion: tls.VersionTLS12, - MaxVersion: tls.VersionTLS12, - CipherSuites: []uint16{ - tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - }, - } - transport.ForceAttemptHTTP2 = false + transport.DisableCompression = true // 服务器不支持压缩 + transport.TLSClientConfig.ServerName = parsedURL.Host // 确保SNI正确 } // 创建HTTP客户端