From 5c69094571d069de0db9a9b64b8eb4a2340658fb Mon Sep 17 00:00:00 2001 From: Scott Lampert Date: Thu, 18 Mar 2021 12:21:36 -0600 Subject: [PATCH] Remove https check for client connection (#489) Removes the https requirement for localhost only. --- server/service/client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/service/client.go b/server/service/client.go index 495ea5c115..587d146374 100644 --- a/server/service/client.go +++ b/server/service/client.go @@ -36,15 +36,15 @@ type ClientOption func(*Client) error func NewClient(addr string, insecureSkipVerify bool, rootCA, urlPrefix string, options ...ClientOption) (*Client, error) { // TODO #265 refactor all optional parameters to functional options // API breaking change, needs a major version release - if !strings.HasPrefix(addr, "https://") { - return nil, errors.New("Address must start with https://") - } - baseURL, err := url.Parse(addr) if err != nil { return nil, errors.Wrap(err, "parsing URL") } + if baseURL.Scheme != "https" && !strings.Contains(baseURL.Host, "localhost") { + return nil, errors.New("address must start with https:// for remote connections") + } + rootCAPool := x509.NewCertPool() if rootCA != "" { // read in the root cert file specified in the context