MySqlConnector icon indicating copy to clipboard operation
MySqlConnector copied to clipboard

Use user-provided callbacks when opening new connection to KILL QUERY

Open OliverSteinau opened this issue 3 years ago • 3 comments
trafficstars

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.

OliverSteinau avatar Jun 05 '22 13:06 OliverSteinau

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.

bgrainger avatar Aug 13 '22 16:08 bgrainger

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.

OliverSteinau avatar Aug 16 '22 12:08 OliverSteinau

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.

bgrainger avatar Aug 16 '22 20:08 bgrainger

Fixed in 2.2.0.

bgrainger avatar Nov 21 '22 02:11 bgrainger