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

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

Closed
OliverSteinau opened this issue Jun 5, 2022 · 4 comments
Closed
Milestone

Comments

@OliverSteinau
Copy link

OliverSteinau commented Jun 5, 2022

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.

@bgrainger
Copy link
Member

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.

@OliverSteinau
Copy link
Author

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.

@bgrainger bgrainger removed the invalid label Aug 16, 2022
@bgrainger bgrainger reopened this Aug 16, 2022
@bgrainger
Copy link
Member

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 bgrainger changed the title "Access denied" when query times out and connection uses SSL Use user-provided callbacks when opening new connection to KILL QUERY Aug 16, 2022
@bgrainger bgrainger added this to the 2.2 milestone Aug 19, 2022
@bgrainger
Copy link
Member

Fixed in 2.2.0.

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

No branches or pull requests

2 participants