From c61380584e592a773343e420b5011bed4df9785e Mon Sep 17 00:00:00 2001 From: Mike Cardwell Date: Thu, 26 Nov 2020 11:12:34 +0000 Subject: [PATCH] Server plugin should use default http transport when scheme is not https --- pkg/plugin/server/http.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/plugin/server/http.go b/pkg/plugin/server/http.go index b6116cea..696f8617 100644 --- a/pkg/plugin/server/http.go +++ b/pkg/plugin/server/http.go @@ -43,17 +43,18 @@ type httpPlugin struct { } func NewHTTPPluginOptions(options HTTPPluginOptions) Plugin { + var url = fmt.Sprintf("%s%s", options.Addr, options.Path) + var client *http.Client - if options.TLSVerify == false { + if strings.HasPrefix(url, "https://") { tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + TLSClientConfig: &tls.Config{InsecureSkipVerify: options.TLSVerify == false}, } client = &http.Client{Transport: tr} } else { client = &http.Client{} } - var url = fmt.Sprintf("%s%s", options.Addr, options.Path) if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "http://") { url = "http://" + url }