From 92ae73aafc0aa4a71b3c8105b4081acf0c4ba2c4 Mon Sep 17 00:00:00 2001 From: ChengXiangdong Date: Wed, 8 Jan 2025 15:46:49 +0800 Subject: [PATCH] feat: add insecure to trust self-signed certificates (#155) --- pkg/config/cloud.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/config/cloud.go b/pkg/config/cloud.go index 6908bc0e..96653755 100644 --- a/pkg/config/cloud.go +++ b/pkg/config/cloud.go @@ -1,6 +1,7 @@ package config import ( + "crypto/tls" "fmt" "net/http" @@ -20,6 +21,7 @@ type CloudCredentials struct { Cloud string `gcfg:"cloud"` AuthURL string `gcfg:"auth-url"` Region string `gcfg:"region"` + Insecure bool `gcfg:"insecure"` AccessKey string `gcfg:"access-key"` SecretKey string `gcfg:"secret-key"` ProjectID string `gcfg:"project-id"` @@ -135,7 +137,14 @@ func (c *CloudCredentials) newCloudClient() error { return err } - transport := &http.Transport{Proxy: http.ProxyFromEnvironment} + transport := &http.Transport{ + Proxy: http.ProxyFromEnvironment, + TLSClientConfig: &tls.Config{ + MinVersion: tls.VersionTLS12, + InsecureSkipVerify: c.Global.Insecure, + }, + } + client.HTTPClient = http.Client{ Transport: &utils.LogRoundTripper{ Rt: transport,