fix: 更新 DownloadFile 函数的 HTTP 传输配置,禁用 HTTP/2 并增强 TLS 证书验证
This commit is contained in:
parent
5b63594110
commit
b42b3ca4d3
21
util/url.go
21
util/url.go
@ -74,19 +74,22 @@ func DownloadFile(urlStr string, dirPath string) (filepath string, err error) {
|
|||||||
|
|
||||||
// 创建基础传输配置
|
// 创建基础传输配置
|
||||||
transport := &http.Transport{
|
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配置
|
// 如果是腾讯的特定域名,使用特殊的TLS配置
|
||||||
if strings.HasSuffix(parsedURL.Host, ".qq.com.cn") {
|
if strings.HasSuffix(parsedURL.Host, ".qq.com.cn") {
|
||||||
transport.TLSClientConfig = &tls.Config{
|
transport.DisableCompression = true // 服务器不支持压缩
|
||||||
MinVersion: tls.VersionTLS12,
|
transport.TLSClientConfig.ServerName = parsedURL.Host // 确保SNI正确
|
||||||
MaxVersion: tls.VersionTLS12,
|
|
||||||
CipherSuites: []uint16{
|
|
||||||
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
transport.ForceAttemptHTTP2 = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建HTTP客户端
|
// 创建HTTP客户端
|
||||||
|
Loading…
x
Reference in New Issue
Block a user