Skip to content

Cannot init MySQL base: Authentication method 'caching_sha2_password' failed. Either use a secure connection, specify the server's RSA public key with ServerRSAPublicKeyFile, or set AllowPublicKeyRetrieval=True. #2

@AlperShal

Description

@AlperShal
�[39;49m�[37m16:03:44�[39;49m�[39;49m�[30m [�[39;49m�[39;49m�[37mINFO�[39;49m�[39;49m�[30m] (cssharp:�[39;49m�[39;49m�[37mPluginContext�[39;49m�[39;49m�[30m) �[39;49m�[39;49m�[37mLoading plugin �[39;49m�[39;49m�[36mPlayerSettings�[39;49m
Cannot init MySQL base: Authentication method 'caching_sha2_password' failed. Either use a secure connection, specify the server's RSA public key with ServerRSAPublicKeyFile, or set AllowPublicKeyRetrieval=True.
Could not load plugin "/data/serverfiles/game/csgo/addons/counterstrikesharp/plugins/PlayerSettings/PlayerSettings.dll"
�[39;49m�[37m16:03:44�[39;49m�[39;49m�[30m [�[39;49m�[39;49m�[37m�[39;49m�[37m�[41mEROR�[39;49m�[39;49m�[30m] (cssharp:�[39;49m�[39;49m�[37mCore�[39;49m�[39;49m�[30m) �[39;49m�[39;49m�[37mCould not load plugin "�[39;49m�[39;49m�[36m/data/serverfiles/game/csgo/addons/counterstrikesharp/plugins/PlayerSettings/PlayerSettings.dll�[39;49m�[39;49m�[37m"�[39;49m
�[39;49m�[37mSystem.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.�[39;49m
�[39;49m�[37m ---> MySqlConnector.MySqlException (0x80004005): Authentication method 'caching_sha2_password' failed. Either use a secure connection, specify the server's RSA public key with ServerRSAPublicKeyFile, or set AllowPublicKeyRetrieval=True.�[39;49m
�[39;49m�[37m   at MySqlConnector.Core.ServerSession.GetRsaPublicKeyAsync(String switchRequestName, ConnectionSettings cs, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 814�[39;49m
�[39;49m�[37m   at MySqlConnector.Core.ServerSession.SwitchAuthenticationAsync(ConnectionSettings cs, String password, PayloadData payload, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 699�[39;49m
�[39;49m�[37m   at MySqlConnector.Core.ServerSession.ConnectAsync(ConnectionSettings cs, MySqlConnection connection, Int64 startingTimestamp, ILoadBalancer loadBalancer, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 532�[39;49m
�[39;49m�[37m   at MySqlConnector.Core.ConnectionPool.ConnectSessionAsync(MySqlConnection connection, Action`4 logMessage, Int64 startingTimestamp, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ConnectionPool.cs:line 427�[39;49m
�[39;49m�[37m   at MySqlConnector.Core.ConnectionPool.ConnectSessionAsync(MySqlConnection connection, Action`4 logMessage, Int64 startingTimestamp, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ConnectionPool.cs:line 432�[39;49m
�[39;49m�[37m   at MySqlConnector.Core.ConnectionPool.GetSessionAsync(MySqlConnection connection, Int64 startingTimestamp, Int32 timeoutMilliseconds, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ConnectionPool.cs:line 109�[39;49m
�[39;49m�[37m   at MySqlConnector.Core.ConnectionPool.GetSessionAsync(MySqlConnection connection, Int64 startingTimestamp, Int32 timeoutMilliseconds, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ConnectionPool.cs:line 142�[39;49m
�[39;49m�[37m   at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int64 startingTimestamp, Activity activity, Nullable`1 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 1056�[39;49m
�[39;49m�[37m   at MySqlConnector.MySqlConnection.OpenAsync(Nullable`1 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 556�[39;49m
�[39;49m�[37m   at MySqlConnector.MySqlConnection.Open() in /_/src/MySqlConnector/MySqlConnection.cs:line 518�[39;49m
�[39;49m�[37m   at AnyBaseLib.Bases.MySQLDriver.GetNewConn(Boolean open) in C:\Users\NickFox\source\repos\AnyApiLib\AnyBaseLib\Bases\MySQL.cs:line 97�[39;49m
�[39;49m�[37m   at AnyBaseLib.Bases.MySQLDriver.QueryAsync(String q, List`1 args, Action`1 action, Boolean non_query) in C:\Users\NickFox\source\repos\AnyApiLib\AnyBaseLib\Bases\MySQL.cs:line 90�[39;49m
�[39;49m�[37m   at PlayerSettings.Storage.Init() in C:\Users\NickFox\source\repos\CSSharp\PlayerSettings\PlayerSettings\Storage.cs:line 35�[39;49m
�[39;49m�[37m   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)�[39;49m
�[39;49m�[37m   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)�[39;49m
�[39;49m�[37m   --- End of inner exception stack trace ---�[39;49m
�[39;49m�[37m   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)�[39;49m
�[39;49m�[37m   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)�[39;49m
�[39;49m�[37m   at CounterStrikeSharp.API.Core.BasePlugin.InitializeConfig(Object instance, Type pluginType) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/BasePlugin.cs:line 393�[39;49m
�[39;49m�[37m   at CounterStrikeSharp.API.Core.Plugin.PluginContext.Load(Boolean hotReload) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/Plugin/PluginContext.cs:line 217�[39;49m
�[39;49m�[37m   at CounterStrikeSharp.API.Core.Plugin.Host.PluginManager.LoadPlugin(String path) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/Plugin/Host/PluginManager.cs:line 125�[39;49m
�[39;49m�[37m   at CounterStrikeSharp.API.Core.Application.OnCSSPluginCommand(CCSPlayerController caller, CommandInfo info) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/Application.cs:line 170�[39;49m
�[39;49m�[37m16:03:44�[39;49m�[39;49m�[30m [�[39;49m�[39;49m�[37mINFO�[39;49m�[39;49m�[30m] (cssharp:�[39;49m�[39;49m�[37mPluginContext�[39;49m�[39;49m�[30m) �[39;49m�[39;49m�[37mLoading plugin �[39;49m�[39;49m�[36mMenuManagerCore�[39;49m
�[39;49m�[37m16:03:44�[39;49m�[39;49m�[30m [�[39;49m�[39;49m�[37mINFO�[39;49m�[39;49m�[30m] (cssharp:�[39;49m�[39;49m�[37mPluginContext�[39;49m�[39;49m�[30m) �[39;49m�[39;49m�[37mFinished loading plugin �[39;49m�[39;49m�[36mMenuManager [Core]�[39;49m
Could not load plugin "/data/serverfiles/game/csgo/addons/counterstrikesharp/plugins/MenuManagerCore/MenuManagerCore.dll"
�[39;49m�[37m16:03:44�[39;49m�[39;49m�[30m [�[39;49m�[39;49m�[37m�[39;49m�[37m�[41mEROR�[39;49m�[39;49m�[30m] (cssharp:�[39;49m�[39;49m�[37mCore�[39;49m�[39;49m�[30m) �[39;49m�[39;49m�[37mCould not load plugin "�[39;49m�[39;49m�[36m/data/serverfiles/game/csgo/addons/counterstrikesharp/plugins/MenuManagerCore/MenuManagerCore.dll�[39;49m�[39;49m�[37m"�[39;49m
�[39;49m�[37mSystem.Collections.Generic.KeyNotFoundException: The given key 'settings:nfcore' was not present in the dictionary.�[39;49m
�[39;49m�[37m   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)�[39;49m
�[39;49m�[37m   at CounterStrikeSharp.API.Core.Capabilities.PluginCapability`1.Get() in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/Capabilities/PluginCapability.cs:line 17�[39;49m
�[39;49m�[37m   at MenuManager.MenuManagerCore.OnAllPluginsLoaded(Boolean hotReload) in C:\Users\NickFox\source\repos\CSSharp\MenuManager\MenuManagerCore\Main.cs:line 58�[39;49m
�[39;49m�[37m   at CounterStrikeSharp.API.Core.Application.OnCSSPluginCommand(CCSPlayerController caller, CommandInfo info) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/Application.cs:line 172�[39;49m

Situation:
I have four Counter-Strike 2 servers running from the same server files. The first one in the boot order almost always (reason to "almost always" is in the next paragraph) throws this error. Others do not ever.

My servers are in a Dockerized environment. If I do docker compose up -d or docker compose restart this error happens. If I just do docker compose restart cs2 (cs2 is the container containing the CS2 servers, and the other container in the compose is MySQL database) everything works as expected.

Explanation for the previous paragraph: If I just restart the servers no problem. If I restart the servers AND the database this error occurs. But only for the first booting server.

Solutions tried:

  • I thought of a possible race condition. First started the database and waited a bit. Then started the CS2 servers but it didn't do any difference. (I think the very first attempt for the connection triggers some changes in the database's behavior. After that other servers are able to connect. That would explain why restarting the servers doesn't cause any problems but restarting the servers AND the database does.)
  • After doing a few googling I came across people suggesting to update MySql connector libraries. I have downloaded your repo, commented <PackageReference>s from AnyBaseLib.csproj and re-added them with dotnet add package "Package Name". After building with dotnet publish AnyBaseLib.csproj and replacing contents of the AnyBaseLib directory on my server with the new ones I built, I again got the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions