MySqlConnector
MySqlConnector copied to clipboard
Use user-provided callbacks when opening new connection to KILL QUERY
Connecting to the server in order to issue "KILL QUERY" command (after query has timed out) fails with "access denied" when "SslMode = MySqlSslMode.Required" is used and a certificate is required.
I can't reproduce this problem. The following code prints 1 (i.e., SLEEP was cancelled) in < 0.6 seconds:
var connection = new MySqlConnection("server=localhost;user id=ssltest;password=test;port=3306;ssl mode=Required;certificate file=C:\\Code\\MySql\\MySqlConnector\\.ci\\server\\certs\\ssl-client.pfx");
connection.Open();
using var command = new MySqlCommand("SELECT SLEEP(10);", connection);
var task = command.ExecuteScalarAsync();
Thread.Sleep(500);
command.Cancel();
Console.WriteLine(task.Result);
Please provide a small self-contained repro.
Sorry, my mistake - I didn't correctly describe the circumstances that lead to this issue. The problem arises when the certificate is needed to authenticate the user (created in MySQL like "create user ... require subject 'xxx' ..."). Since the connection which is used to cancel the request is created by using the stored ConnectionString, it will fail with "access denied", because the certificate is not sent. In my case, the certificate is being set using the ProvideClientCertificatesCallback.
OK, that makes sense.
Likely all of ProvideClientCertificatesCallback, ProvidePasswordCallback and RemoteCertificateValidationCallback need to be used when creating the new connection that is used to cancel an existing query.
Fixed in 2.2.0.