diff options
| author | Patrick Lee <pattyshack101@gmail.com> | 2016-11-11 19:24:07 -0800 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-11-12 18:30:15 +0000 |
| commit | 2f497263e4ff6121a1ba80e7a57e950061896626 (patch) | |
| tree | 8ba7ea43bb65047b4e5ee8092f58190fc5a93b97 /src/cmd/pprof | |
| parent | 4966150af0139b5f26a943eb4c33fe5cb6758043 (diff) | |
| download | go-2f497263e4ff6121a1ba80e7a57e950061896626.tar.xz | |
cmd/pprof: add options to skip tls verification
Don't verify tls host when profiling https+insecure://host/port/...,
as per discussion in https://go-review.googlesource.com/#/c/20885/.
Fixes: #11468
Change-Id: Ibfc236e5442a00339334602a4014e017c62d9e7a
Reviewed-on: https://go-review.googlesource.com/33157
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/pprof')
| -rw-r--r-- | src/cmd/pprof/internal/fetch/fetch.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/cmd/pprof/internal/fetch/fetch.go b/src/cmd/pprof/internal/fetch/fetch.go index 2e2de575f8..d3ccb65473 100644 --- a/src/cmd/pprof/internal/fetch/fetch.go +++ b/src/cmd/pprof/internal/fetch/fetch.go @@ -7,6 +7,7 @@ package fetch import ( + "crypto/tls" "fmt" "io" "io/ioutil" @@ -72,11 +73,26 @@ func PostURL(source, post string) ([]byte, error) { // httpGet is a wrapper around http.Get; it is defined as a variable // so it can be redefined during for testing. -var httpGet = func(url string, timeout time.Duration) (*http.Response, error) { +var httpGet = func(source string, timeout time.Duration) (*http.Response, error) { + url, err := url.Parse(source) + if err != nil { + return nil, err + } + + var tlsConfig *tls.Config + if url.Scheme == "https+insecure" { + tlsConfig = &tls.Config{ + InsecureSkipVerify: true, + } + url.Scheme = "https" + source = url.String() + } + client := &http.Client{ Transport: &http.Transport{ ResponseHeaderTimeout: timeout + 5*time.Second, + TLSClientConfig: tlsConfig, }, } - return client.Get(url) + return client.Get(source) } |
