Skip to content

Commit 2f49726

Browse files
pattyshackbradfitz
authored andcommitted
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 <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 4966150 commit 2f49726

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/cmd/pprof/internal/fetch/fetch.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package fetch
88

99
import (
10+
"crypto/tls"
1011
"fmt"
1112
"io"
1213
"io/ioutil"
@@ -72,11 +73,26 @@ func PostURL(source, post string) ([]byte, error) {
7273

7374
// httpGet is a wrapper around http.Get; it is defined as a variable
7475
// so it can be redefined during for testing.
75-
var httpGet = func(url string, timeout time.Duration) (*http.Response, error) {
76+
var httpGet = func(source string, timeout time.Duration) (*http.Response, error) {
77+
url, err := url.Parse(source)
78+
if err != nil {
79+
return nil, err
80+
}
81+
82+
var tlsConfig *tls.Config
83+
if url.Scheme == "https+insecure" {
84+
tlsConfig = &tls.Config{
85+
InsecureSkipVerify: true,
86+
}
87+
url.Scheme = "https"
88+
source = url.String()
89+
}
90+
7691
client := &http.Client{
7792
Transport: &http.Transport{
7893
ResponseHeaderTimeout: timeout + 5*time.Second,
94+
TLSClientConfig: tlsConfig,
7995
},
8096
}
81-
return client.Get(url)
97+
return client.Get(source)
8298
}

0 commit comments

Comments
 (0)