Intermittent incorrect error message?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
taz
Posts: 1
Joined: Tue 31 Dec 2013 16:51

Intermittent incorrect error message?

Post by taz » Tue 31 Dec 2013 18:03

When attempting to open a SSL connection to a MySql user that has no privileges, an alternate exception is thrown approximately 1/5 of the time. The correct exception is:

Code: Select all

Devart.Data.MySql.MySqlException
Message = Access denied for user [...] to database [...]
SqlState = 42000
Code = 1044
InnerException = null
The incorrect exception is:

Code: Select all

Devart.Data.MySql.MySqlException
Message = Can't connect to MySQL server on [...] (10061): Authentication failed
SqlState = 00000
Code = 2003
InnerException: Devart.Common.aj
    Message = Transport channel is closed
From http://dev.mysql.com/doc/refman/5.1/en/ ... erver.html:
The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server.
From http://dev.mysql.com/doc/refman/5.1/en/ ... erver.html:
Error: 1044 SQLSTATE: 42000 (ER_DBACCESS_DENIED_ERROR)
Message: Access denied for user '%s'@'%s' to database '%s'
Here is a C# SSCE to demonstrate. Note that the MySQL user must have no privileges to open a connection to the given database. For ease of use, the database credentials are parameters.

Code: Select all

using System;

namespace DevartSSCE
{
    class Program
    {
        static void Main(string[] args)
        {
            int test = 0;
            for (int i = 0; i < 100; i++)
            {
                if (go(args))
                {
                    test++;
                }                
            }
            Console.WriteLine("Incorrect: " + test);
            Console.WriteLine();
            Console.WriteLine("\nPress enter to exit");
            Console.Read();
        }

        static bool go(string[] args)
        {
            string user = args[0];
            string pass = args[1];
            string host = args[2];
            string schema = args[3];
            string ssl_ca = args[4];
            string ssl_cert = args[5];
            string ssl_key = args[6];

            bool otherExceptionCaught = false;
            string connStr = "User Id=" + user + ";" +
                "Password=" + pass + ";" +
                "Host=" + host + ";" +
                "Database=" + schema + ";" +
                "Protocol=Ssl;" +
                "Pooling=False;" +
                "SSL CA Cert=file://" + ssl_ca + ";" +
                "SSL Cert=file://" + ssl_cert + ";" +
                "SSL Key=file://" + ssl_key + ";" +
                "Validate Connection=True;";
            Devart.Data.MySql.MySqlConnection conn = new Devart.Data.MySql.MySqlConnection(connStr);
            try
            {
                conn.Open();
            }
            catch (Devart.Data.MySql.MySqlException ex)
            {
                if (ex.Message == "Access denied for user '" + user + "'@'" + host + "' to database '" + schema + "'")
                {
                    Console.WriteLine("Correct exception caught");
                }
                else if (ex.Message == "Can't connect to MySQL server on '" + host + "' (10061): Authentication failed.")
                {
                    otherExceptionCaught = true;
                    Console.WriteLine("Incorrect exception caught");
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                conn.Close();
            }
            return otherExceptionCaught;
        }
    }
}
Tested with MySQL 5.1 server on localhost using dotConnect for MySQL 8.2.65 trial edition. When the incorrect exception is thrown, MySql does log the connection attempt identically to when the correct exception is thrown.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Intermittent incorrect error message?

Post by Shalex » Mon 06 Jan 2014 14:49

Thank you for the report. We have reproduced the issue and are investigating it.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Intermittent incorrect error message?

Post by Shalex » Mon 27 Jan 2014 10:05

The bug with incorrect error message when authenticating with limited privileges is fixed. We will notify you when the corresponding build of dotConnect for MySQL is available for download.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Intermittent incorrect error message?

Post by Shalex » Thu 30 Jan 2014 15:50

New build of dotConnect for MySQL 8.2.90 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/mysql/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=2&t=28829.

Post Reply