From 548929b2e81f8bded5bdbd6bac9a378cbab0739a Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Sun, 25 May 2025 16:15:34 +0800 Subject: [PATCH] fix: Alibaba Cloud Disk ignores tls verification (#8812) --- agent/utils/cloud_storage/client/ali.go | 25 +++++++++++++++++++++++++ core/utils/cloud_storage/client/ali.go | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/agent/utils/cloud_storage/client/ali.go b/agent/utils/cloud_storage/client/ali.go index d52fb4ce2..a5b970e49 100644 --- a/agent/utils/cloud_storage/client/ali.go +++ b/agent/utils/cloud_storage/client/ali.go @@ -1,6 +1,7 @@ package client import ( + "crypto/tls" "encoding/json" "errors" "fmt" @@ -57,6 +58,9 @@ func (a aliClient) Delete(pathItem string) (bool, error) { return false, err } client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "drive_id": a.driveID, "file_id": fileInfo.FileID, @@ -104,6 +108,9 @@ func (a aliClient) Upload(src, target string) (bool, error) { "check_name_mode": "auto_rename", } client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) url := "https://api.alipan.com/v2/file/create" resp, err := client.R(). @@ -138,6 +145,9 @@ func (a aliClient) Download(src, target string) (bool, error) { return false, err } client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) if fileInfo.Size > 100*1024*1024 { return false, fmt.Errorf("The translation file %s exceeds 100MB, please download it through the client.", src) } @@ -255,6 +265,9 @@ func (a aliClient) loadDirWithPath(path string) ([]fileInfo, error) { func (a aliClient) loadFileWithParentID(parentID string) ([]fileInfo, error) { client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "drive_id": a.driveID, "fields": "*", @@ -324,6 +337,9 @@ func (a aliClient) mkdirWithPath(target string) (string, error) { func (a aliClient) mkdir(parentID, name string) (string, error) { client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "drive_id": a.driveID, "name": name, @@ -455,6 +471,9 @@ func (a aliClient) handleDownload(uri string, target string) error { func (a *aliClient) completeUpload(uploadID, fileID string) error { client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "drive_id": a.driveID, "upload_id": uploadID, @@ -482,6 +501,9 @@ type tokenResp struct { func loadToken(refresh_token string) (string, error) { client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "grant_type": "refresh_token", "refresh_token": refresh_token, @@ -511,6 +533,9 @@ func RefreshALIToken(varMap map[string]interface{}) (string, error) { return "", errors.New("no such refresh token find in db") } client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "grant_type": "refresh_token", "refresh_token": refresh_token, diff --git a/core/utils/cloud_storage/client/ali.go b/core/utils/cloud_storage/client/ali.go index 34ed27557..1dd1dc314 100644 --- a/core/utils/cloud_storage/client/ali.go +++ b/core/utils/cloud_storage/client/ali.go @@ -1,6 +1,7 @@ package client import ( + "crypto/tls" "encoding/json" "errors" "fmt" @@ -61,6 +62,9 @@ func (a aliClient) Upload(src, target string) (bool, error) { "check_name_mode": "auto_rename", } client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) url := "https://api.alipan.com/v2/file/create" resp, err := client.R(). @@ -95,6 +99,9 @@ func (a aliClient) Delete(pathItem string) (bool, error) { return false, err } client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "drive_id": a.driveID, "file_id": fileInfo.FileID, @@ -153,6 +160,9 @@ func (a aliClient) loadFileWithName(pathItem string) (fileInfo, error) { func (a aliClient) loadFileWithParentID(parentID string) ([]fileInfo, error) { client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "drive_id": a.driveID, "fields": "*", @@ -222,6 +232,9 @@ func (a aliClient) mkdirWithPath(target string) (string, error) { func (a aliClient) mkdir(parentID, name string) (string, error) { client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "drive_id": a.driveID, "name": name, @@ -316,6 +329,9 @@ func (a aliClient) uploadPart(uri string, reader io.Reader) error { func (a *aliClient) completeUpload(uploadID, fileID string) error { client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "drive_id": a.driveID, "upload_id": uploadID, @@ -347,6 +363,9 @@ func RefreshALIToken(varMap map[string]interface{}) (string, error) { return "", errors.New("no such refresh token find in db") } client := resty.New() + client.SetTLSClientConfig(&tls.Config{ + InsecureSkipVerify: true, + }) data := map[string]interface{}{ "grant_type": "refresh_token", "refresh_token": refresh_token,