From ade633a9af258e43ae54c8e4d3930088299aa36d Mon Sep 17 00:00:00 2001 From: Jay Wren Date: Mon, 11 Oct 2021 13:16:22 -0400 Subject: [PATCH] Verify TLS and add -k to disable --- hey.go | 3 +++ requester/requester.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hey.go b/hey.go index f727e26b..387e6c16 100644 --- a/hey.go +++ b/hey.go @@ -57,6 +57,7 @@ var ( t = flag.Int("t", 20, "") z = flag.Duration("z", 0, "") + k = flag.Bool("k", false, "") h2 = flag.Bool("h2", false, "") cpus = flag.Int("cpus", runtime.GOMAXPROCS(-1), "") @@ -91,6 +92,7 @@ Options: -U User-Agent, defaults to version "hey/0.0.1". -a Basic authentication, username:password. -x HTTP Proxy address as host:port. + -k Allow insecure server connections when using SSL. -h2 Enable HTTP/2. -host HTTP Host header. @@ -232,6 +234,7 @@ func main() { DisableKeepAlives: *disableKeepAlives, DisableRedirects: *disableRedirects, H2: *h2, + K: *k, ProxyAddr: proxyURL, Output: *output, } diff --git a/requester/requester.go b/requester/requester.go index fd7277e7..ed993022 100644 --- a/requester/requester.go +++ b/requester/requester.go @@ -63,6 +63,9 @@ type Work struct { // C is the concurrency level, the number of concurrent workers to run. C int + // K is an option to allow insecure server connections when using SSL. + K bool + // H2 is an option to make HTTP/2 requests H2 bool @@ -237,7 +240,7 @@ func (b *Work) runWorkers() { tr := &http.Transport{ TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, + InsecureSkipVerify: b.K, ServerName: b.Request.Host, }, MaxIdleConnsPerHost: min(b.C, maxIdleConn),