From 5459f29cc89d62c92f4e82fdb92a0b4841320fbf Mon Sep 17 00:00:00 2001 From: Victor Luchits Date: Mon, 27 Jun 2022 12:47:17 +0300 Subject: [PATCH] Fix initialization of TLS connections --- client/conn.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/conn.go b/client/conn.go index 5cbe30025..bc602c413 100644 --- a/client/conn.go +++ b/client/conn.go @@ -84,16 +84,11 @@ func ConnectWithDialer(ctx context.Context, network string, addr string, user st return nil, errors.Trace(err) } - if c.tlsConfig != nil { - c.Conn = packet.NewTLSConn(conn) - } else { - c.Conn = packet.NewConn(conn) - } - c.user = user c.password = password c.db = dbName c.proto = network + c.Conn = packet.NewConn(conn) // use default charset here, utf-8 c.charset = DEFAULT_CHARSET @@ -103,6 +98,12 @@ func ConnectWithDialer(ctx context.Context, network string, addr string, user st options[i](c) } + if c.tlsConfig != nil { + seq := c.Conn.Sequence + c.Conn = packet.NewTLSConn(conn) + c.Conn.Sequence = seq + } + if err = c.handshake(); err != nil { return nil, errors.Trace(err) }