Remove https check for client connection (#489)

Removes the https requirement for localhost only.
This commit is contained in:
Scott Lampert 2021-03-18 12:21:36 -06:00 committed by GitHub
parent 4691ac9629
commit 5c69094571
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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