Skip to content
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

Can't authenticate with MySQL Server 5.1 #139

Closed
yukozh opened this issue Nov 23, 2016 · 4 comments
Closed

Can't authenticate with MySQL Server 5.1 #139

yukozh opened this issue Nov 23, 2016 · 4 comments
Assignees
Milestone

Comments

@yukozh
Copy link

@yukozh yukozh commented Nov 23, 2016

Author: @mguinness
Date: Nov 23rd
Original Issue: PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#123


Using MySQL version 5.1.38 on Windows I get the following error, but using MySQL version 5.6.27 on Linux I do not. Also this isn't an issue with either the official MySql or Sapient Guardian providers, Any ideas/suggestions?

System.NotSupportedException: Authentication method '' is not supported.
   at MySql.Data.Serialization.MySqlSession.<ConnectAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.ConnectionPool.<GetSessionAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.MySqlConnection.<CreateSessionAsync>d__55.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.MySqlConnection.<OpenAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlRelationalConnection.Open()
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer)
   at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()
   at Microsoft.EntityFrameworkCore.Query.Internal.MySqlQueryingEnumerable`1.MySqlEnumerator.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at lambda_method(Closure , QueryContext )
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_0`1.<CompileQueryCore>b__0(QueryContext qc)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
   at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.Find(Object[] keyValues)
   at DataQuery.Controllers.HomeController.Index() in C:\Projects\DataQuery\src\DataQuery\Controllers\HomeController.cs:line 55

Further technical details

MySQL version: 5.1.38-community
Operating system: Windows Server 2008 R2
Pomelo.EntityFrameworkCore.MySql version: 1.1.0-rtm-10003 (MySqlConnector 0.7.0)

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Nov 23, 2016

MySQL Server 5.1 doesn't support authentication plugins, which is not handled correctly by this library. (The earliest version that has been tested for compatibility is MySQL Server 5.5.)

From Determining Authentication Method:

in MySQL 5.5 arbitrary authentication methods can be implemented by means of authentication plugins.

If client or server do not support pluggable authentication (CLIENT_PLUGIN_AUTH capability flag is not set) then the authentication method used is inferred from client and server capabilities as follows:

  • The method used is Old Password Authentication if CLIENT_PROTOCOL_41 or CLIENT_SECURE_CONNECTION are not set.
  • The method used is Secure Password Authentication if both CLIENT_PROTOCOL_41 and CLIENT_SECURE_CONNECTION are set but CLIENT_PLUGIN_AUTH is not set.

The fix will be to check InitialHandshakePacket. ProtocolCapabilities.HasFlag(ProtocolCapabilities.PluginAuth) here and fall back to using "old" or "secure" authentication based on the ProtocolCapabilities.SecureConnection flag. (This would also be a good time to implement Old Password Authentication.)

@bgrainger bgrainger added this to the 1.0 milestone Nov 23, 2016
@bgrainger bgrainger changed the title Authentication method '' is not supported Can't authenticate with MySQL Server 5.1 Nov 23, 2016
@bgrainger
Copy link
Member

@bgrainger bgrainger commented Nov 23, 2016

Fixed in 0.7.2.

@bgrainger bgrainger self-assigned this Nov 23, 2016
@bgrainger
Copy link
Member

@bgrainger bgrainger commented Nov 23, 2016

This would also be a good time to implement Old Password Authentication.

This was not implemented, as it's only necessary for pre-4.1 MySQL Servers, which doesn't seem worth supporting.

@mguinness
Copy link
Contributor

@mguinness mguinness commented Nov 24, 2016

Confirmed fixed, thanks to all those that contributed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants