Skip to content

Commit fb14715

Browse files
Bug#14751925: USELESS ERROR MESSAGE WHEN SHA-256
CONNECTION FAILS BECAUSE OF MISSING SSL/RSA Description: Client side code supporting pluggable authentication assumes that an error can be raised by server and there is no consideration for the possibility that client plugin denied the access. Hence error becomes "MySQL Unknown Error". This patch fixes this issue for sha256 client plugin and introduces client side error with required description.
1 parent 131ae8e commit fb14715

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

include/errmsg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ extern const char *client_errors[]; /* Error messages */
103103
#define CR_ALREADY_CONNECTED 2058
104104
#define CR_AUTH_PLUGIN_CANNOT_LOAD 2059
105105
#define CR_DUPLICATE_CONNECTION_ATTR 2060
106-
#define CR_ERROR_LAST /*Copy last error nr:*/ 2060
106+
#define CR_AUTH_PLUGIN_ERR 2061
107+
#define CR_ERROR_LAST /*Copy last error nr:*/ 2061
107108
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
108109

109110
#endif /* ERRMSG_INCLUDED */

libmysql/errmsg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const char *client_errors[]=
8585
"The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
8686
"This handle is already connected. Use a separate handle for each connection.",
8787
"Authentication plugin '%s' cannot be loaded: %s",
88+
"There is an attribute with the same name already",
89+
"Authentication plugin '%s' reported error: %s",
8890
""
8991
};
9092

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Only run this test if YaSSL is supported
2+
let $shavars= query_get_value("SELECT COUNT(*) as shavars FROM information_schema.session_variables WHERE variable_name = 'sha256_password_private_key_path'", shavars, 1);
3+
if ($shavars != 0){
4+
skip Need YaSSL support;
5+
}

sql-common/client_authentication.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ int sha256_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
232232
if (vio->write_packet(vio, (uchar*) encrypted_password, cipher_length))
233233
DBUG_RETURN(CR_ERROR);
234234
#else
235-
DBUG_RETURN(CR_ERROR); // If no yassl support
235+
set_mysql_extended_error(mysql, CR_AUTH_PLUGIN_ERR, unknown_sqlstate,
236+
ER(CR_AUTH_PLUGIN_ERR), "sha256_password",
237+
"Authentication requires SSL encryption");
238+
DBUG_RETURN(CR_ERROR); // If no openssl support
236239
#endif
237240
}
238241
else

0 commit comments

Comments
 (0)