From 5ffdcbdffcde95d6998bbd975c72f6c89bfb43db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20B?= <{ID}+{username}@users.noreply.github.com> Date: Tue, 25 Jun 2019 15:29:41 +0200 Subject: [PATCH] Add insecure option to disable cert validation --- speedtest.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/speedtest.go b/speedtest.go index 17956fb..248fb73 100644 --- a/speedtest.go +++ b/speedtest.go @@ -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() @@ -40,7 +41,7 @@ func main() { kingpin.Parse() setTimeout() - setCertVerify(false) + setCertVerify(*insecure) user := fetchUserInfo() user.Show()