Software versions
MySqlConnector version: 2.3.7
Server type (MySQL, MariaDB, Aurora, etc.) and version: MariaDB on RDS
.NET version: 6.0
(Optional) ORM NuGet packages and versions:
Describe the bug
When cancelling a command (via CancellationToken or CommandTimeout), the cancel fails to authenticate to the database instance because the cancel tries to open a connection with the ip of the session, which fails cert validation
Logs
2024-10-03 16:08:13.700 {"EventId":0,"LogLevel":"Debug","Category":"MySqlConnector.MySqlConnection","Message":"Session 2.4 made connection; server version 5.5.5-10.11.8-MariaDB-log; connection ID 376807; supports: compression False, attributes True, deprecate EOF True, cached metadata True, SSL True, session track True, pipelining True, query attributes False","State":{"Message":"Session 2.4 made connection; server version 5.5.5-10.11.8-MariaDB-log; connection ID 376807; supports: compression False, attributes True, deprecate EOF True, cached metadata True, SSL True, session track True, pipelining True, query attributes False"}}
2024-10-03 16:08:13.778 {"EventId":0,"LogLevel":"Debug","Category":"MySqlConnector.MySqlConnection","Message":"Session 2.4 connected TLS using Tls13 and TLS_AES_256_GCM_SHA384","State":{"Message":"Session 2.4 connected TLS using Tls13 and TLS_AES_256_GCM_SHA384"}}
2024-10-03 16:12:25.060 {"EventId":0,"LogLevel":"Debug","Category":"MySqlConnector.MySqlConnection","Message":"Session 2.4 will cancel command 105990 (1 attempts); CommandText: [REDACTED]","State":{"Message":"Session 2.4 will cancel command 105990 (1 attempts); CommandText: [REDACTED]"}}
2024-10-03 16:12:25.184 {"EventId":0,"LogLevel":"Information","Category":"MySqlConnector.MySqlConnection","Message":"Session 2.4 cancelling command 105990 failed","Exception":"MySqlConnector.MySqlException (0x80004005): SSL Authentication Error ---\u003E System.Security.Authentication.AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback. at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception) at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm) at System.Net.Security.SslStream.ProcessAuthenticationWithTelemetryAsync(Boolean isAsync, Boolean isApm, CancellationToken cancellationToken) at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions) at MySqlConnector.Core.ServerSession.InitSslAsync(ProtocolCapabilities serverCapabilities, ConnectionSettings cs, MySqlConnection connection, SslProtocols sslProtocols, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 1474 at MySqlConnector.Core.ServerSession.InitSslAsync(ProtocolCapabilities serverCapabilities, ConnectionSettings cs, MySqlConnection connection, SslProtocols sslProtocols, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 1501 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 518 at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int64 startingTimestamp, Activity activity, Nullable\u00601 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 1103 at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int64 startingTimestamp, Activity activity, Nullable\u00601 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 1103 at MySqlConnector.MySqlConnection.OpenAsync(Nullable\u00601 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 590 at MySqlConnector.MySqlConnection.Open() in /_/src/MySqlConnector/MySqlConnection.cs:line 518 at MySqlConnector.MySqlConnection.Cancel(ICancellableCommand command, Int32 commandId, Boolean isCancel) in /_/src/MySqlConnector/MySqlConnection.cs:line 904","State":{"Message":"Session 2.4 cancelling command 105990 failed"}}
2024-10-03 16:12:25.184 {"EventId":0,"LogLevel":"Debug","Category":"MySqlConnector.MySqlConnection","Message":"Session 2.4 will cancel command 105990 (2 attempts); CommandText: [REDACTED]","State":{"Message":"Session 2.4 will cancel command 105990 (2 attempts); CommandText: [REDACTED]"}}
2024-10-03 16:12:25.253 {"EventId":0,"LogLevel":"Information","Category":"MySqlConnector.MySqlConnection","Message":"Session 2.4 cancelling command 105990 failed","Exception":"MySqlConnector.MySqlException (0x80004005): SSL Authentication Error ---\u003E System.Security.Authentication.AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback. at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception) at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm) at System.Net.Security.SslStream.ProcessAuthenticationWithTelemetryAsync(Boolean isAsync, Boolean isApm, CancellationToken cancellationToken) at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions) at MySqlConnector.Core.ServerSession.InitSslAsync(ProtocolCapabilities serverCapabilities, ConnectionSettings cs, MySqlConnection connection, SslProtocols sslProtocols, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 1474 at MySqlConnector.Core.ServerSession.InitSslAsync(ProtocolCapabilities serverCapabilities, ConnectionSettings cs, MySqlConnection connection, SslProtocols sslProtocols, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 1501 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 518 at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int64 startingTimestamp, Activity activity, Nullable\u00601 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 1103 at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int64 startingTimestamp, Activity activity, Nullable\u00601 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 1103 at MySqlConnector.MySqlConnection.OpenAsync(Nullable\u00601 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 590 at MySqlConnector.MySqlConnection.Open() in /_/src/MySqlConnector/MySqlConnection.cs:line 518 at MySqlConnector.MySqlConnection.Cancel(ICancellableCommand command, Int32 commandId, Boolean isCancel) in /_/src/MySqlConnector/MySqlConnection.cs:line 904","State":{"Message":"Session 2.4 cancelling command 105990 failed"}}
Expected behavior
Connection should succeed and cancel the query
Software versions MySqlConnector version: 2.3.7 Server type (MySQL, MariaDB, Aurora, etc.) and version: MariaDB on RDS .NET version: 6.0 (Optional) ORM NuGet packages and versions:
Describe the bug When cancelling a command (via CancellationToken or CommandTimeout), the cancel fails to authenticate to the database instance because the cancel tries to open a connection with the ip of the session, which fails cert validation
Logs
Expected behavior Connection should succeed and cancel the query
Additional context I believe the issue is here https://github.com/mysql-net/MySqlConnector/blob/8107efe38700db5b708a9c776719e5074594e299/src/MySqlConnector/MySqlConnection.cs#L898-L902