File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ func (d MySQLDriver) Open(dsn string) (driver.Conn, error) {
101
101
}
102
102
103
103
// Handle response to auth packet, switch methods if possible
104
- if err = handleAuthResult (mc ); err != nil {
104
+ if err = handleAuthResult (mc , cipher ); err != nil {
105
105
// Authentication failed and MySQL has already closed the connection
106
106
// (https://dev.mysql.com/doc/internals/en/authentication-fails.html).
107
107
// Do not send COM_QUIT, just cleanup and return the error.
@@ -134,7 +134,7 @@ func (d MySQLDriver) Open(dsn string) (driver.Conn, error) {
134
134
return mc , nil
135
135
}
136
136
137
- func handleAuthResult (mc * mysqlConn ) error {
137
+ func handleAuthResult (mc * mysqlConn , oldCipher [] byte ) error {
138
138
// Read Result Packet
139
139
cipher , err := mc .readResultOK ()
140
140
if err == nil {
@@ -150,6 +150,13 @@ func handleAuthResult(mc *mysqlConn) error {
150
150
// Retry with old authentication method. Note: there are edge cases
151
151
// where this should work but doesn't; this is currently "wontfix":
152
152
// https://github.com/go-sql-driver/mysql/issues/184
153
+
154
+ // If CLIENT_PLUGIN_AUTH capability is not supported, no new cipher is
155
+ // sent and we have to keep using the cipher sent in the init packet.
156
+ if cipher == nil {
157
+ cipher = oldCipher
158
+ }
159
+
153
160
if err = mc .writeOldAuthPacket (cipher ); err != nil {
154
161
return err
155
162
}
Original file line number Diff line number Diff line change @@ -499,6 +499,7 @@ func (mc *mysqlConn) readResultOK() ([]byte, error) {
499
499
return cipher , ErrUnknownPlugin
500
500
}
501
501
} else {
502
+ // https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::OldAuthSwitchRequest
502
503
return nil , ErrOldPassword
503
504
}
504
505
You can’t perform that action at this time.
0 commit comments