From a55c63132713354f1548f6c652411ff2a9f633f0 Mon Sep 17 00:00:00 2001 From: Ales Verbic Date: Wed, 23 Oct 2024 09:51:26 -0400 Subject: [PATCH] feat: update client for TLS Signed-off-by: Ales Verbic --- main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index c5c19a2..2a979c0 100644 --- a/main.go +++ b/main.go @@ -64,11 +64,18 @@ func createHttpClient() *http.Client { }, Transport: &http2.Transport{ AllowHTTP: true, - DialTLS: func(network, addr string, _ *tls.Config) (net.Conn, error) { + DialTLS: func(network, addr string, tlsConfig *tls.Config) (net.Conn, error) { // If you're also using this client for non-h2c traffic, you may want // to delegate to tls.Dial if the network isn't TCP or the addr isn't // in an allowlist. - return net.Dial(network, addr) + // return net.Dial(network, addr) + + // Establish a TLS connection using the custom TLS configuration + conn, err := tls.Dial(network, addr, tlsConfig) + if err != nil { + return nil, fmt.Errorf("failed to establish TLS connection: %w", err) + } + return conn, nil }, }, }