Skip to content

Fix initialization of TLS connections #706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packet.NewConn(conn) just created some buffer, it didn't write MySQL data so I think Sequence is untouched.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet it could be modified via an option call since it's a public field

}

if err = c.handshake(); err != nil {
return nil, errors.Trace(err)
}
Expand Down