1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 22:18:07 +08:00

feat: 远程下载文件忽略证书 (#3188)

Refs https://github.com/1Panel-dev/1Panel/issues/2950
This commit is contained in:
zhengkunwang 2023-12-05 16:30:10 +08:00 committed by GitHub
parent 5f9073cb85
commit 592a1b1150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"archive/zip" "archive/zip"
"bufio" "bufio"
"context" "context"
"crypto/tls"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/backend/utils/cmd" "github.com/1Panel-dev/1Panel/backend/utils/cmd"
@ -216,7 +217,11 @@ func (w *WriteCounter) SaveProcess() {
} }
func (f FileOp) DownloadFileWithProcess(url, dst, key string) error { func (f FileOp) DownloadFileWithProcess(url, dst, key string) error {
client := &http.Client{} client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
request, err := http.NewRequest("GET", url, nil) request, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {
return nil return nil

View File

@ -2,6 +2,7 @@ package http
import ( import (
"context" "context"
"crypto/tls"
"errors" "errors"
"github.com/1Panel-dev/1Panel/backend/buserr" "github.com/1Panel-dev/1Panel/backend/buserr"
"net" "net"
@ -14,6 +15,7 @@ func GetHttpRes(url string) (*http.Response, error) {
client := &http.Client{ client := &http.Client{
Timeout: time.Second * 300, Timeout: time.Second * 300,
Transport: &http.Transport{ Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
DialContext: (&net.Dialer{ DialContext: (&net.Dialer{
Timeout: 60 * time.Second, Timeout: 60 * time.Second,
KeepAlive: 60 * time.Second, KeepAlive: 60 * time.Second,