Skip to content

Commit

Permalink
Add insecure option to disable cert validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien B authored and Sébastien B committed Jun 25, 2019
1 parent 09b334e commit 5ffdcbd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ func setTimeout() {
}
}

func setCertVerify(verify bool) {
func setCertVerify(insecure bool) {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
InsecureSkipVerify: !verify,
InsecureSkipVerify: insecure,
}
}

var (
insecure = kingpin.Flag("insecure", "Disable TLS certificate verify").Short('i').Bool()
showList = kingpin.Flag("list", "Show available speedtest.net servers").Short('l').Bool()
serverIds = kingpin.Flag("server", "Select server id to speedtest").Short('s').Ints()
timeoutOpt = kingpin.Flag("timeout", "Define timeout seconds. Default: 10 sec").Short('t').Int()
Expand All @@ -40,7 +41,7 @@ func main() {
kingpin.Parse()

setTimeout()
setCertVerify(false)
setCertVerify(*insecure)

user := fetchUserInfo()
user.Show()
Expand Down

0 comments on commit 5ffdcbd

Please sign in to comment.