From dd7f2ef3fd8be014e0dab092a13af6f5d90a8c89 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 26 May 2020 15:10:14 +0800 Subject: [PATCH] add config for insecure skip verify --- client.go | 9 ++++++++- conf.go | 13 +++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/client.go b/client.go index 34fc47a..aabfec5 100644 --- a/client.go +++ b/client.go @@ -2,6 +2,7 @@ package agollo import ( "context" + "crypto/tls" "encoding/json" "fmt" "net/http" @@ -37,7 +38,13 @@ type result struct { // NewClient create client from conf func NewClient(conf *Conf) *Client { conf.normalize() - httpClient := &http.Client{Timeout: queryTimeout} + httpClient := &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: conf.InsecureSkipVerify}, + }, + Timeout: queryTimeout, + } + agolloClient := &Client{ conf: conf, caches: newNamespaceCahce(), diff --git a/conf.go b/conf.go index 5c33f88..5e788cf 100644 --- a/conf.go +++ b/conf.go @@ -7,12 +7,13 @@ import ( // Conf ... type Conf struct { - AppID string `json:"appId,omitempty"` - Cluster string `json:"cluster,omitempty"` - NameSpaceNames []string `json:"namespaceNames,omitempty"` - CacheDir string `json:"cacheDir,omitempty"` - MetaAddr string `json:"meta_addr"` - AccesskeySecret string `json:"accesskey_secret"` + AppID string `json:"appId,omitempty"` + Cluster string `json:"cluster,omitempty"` + NameSpaceNames []string `json:"namespaceNames,omitempty"` + CacheDir string `json:"cacheDir,omitempty"` + MetaAddr string `json:"meta_addr"` + AccesskeySecret string `json:"accesskey_secret"` + InsecureSkipVerify bool `json:"insecure_skip_verify"` } // NewConf create Conf from file