diff --git a/https.go b/https.go index 0af46222..6d20e04a 100644 --- a/https.go +++ b/https.go @@ -76,7 +76,7 @@ func (proxy *ProxyHttpServer) dial(ctx *ProxyCtx, network, addr string) (c net.C return ctx.Dialer(ctx.Req.Context(), network, addr) } - if proxy.Tr.DialContext != nil { + if proxy.Tr != nil && proxy.Tr.DialContext != nil { return proxy.Tr.DialContext(ctx.Req.Context(), network, addr) } @@ -651,5 +651,9 @@ func (proxy *ProxyHttpServer) initializeTLSconnection( if ctx.InitializeTLS != nil { return ctx.InitializeTLS(targetConn, tlsConfig) } - return tls.Client(targetConn, tlsConfig), nil + tlsConn := tls.Client(targetConn, tlsConfig) + if err := tlsConn.Handshake(); err != nil { + return nil, err + } + return tlsConn, nil }