-
Notifications
You must be signed in to change notification settings - Fork 338
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
No credentials are available in the security package #1278
Comments
Workaround (according to dotnet/runtime#23749) Modify this file src\MySqlConnector\Core\ServerSession.cs
|
The https://github.com/mysql-net/MySqlConnector/blob/master/tests/IntegrationTests/SslTests.cs#L76-L95 |
Thanks for the bug report; the workaround that you identified seems like the right approach. In the meantime, you can use var myBuilder =
new MySqlConnectionStringBuilder(@"Server=XXXXX;User ID=YYYY;Password=ZZZZZZ;Database=QQQQQ");
myBuilder.SslCa = @"G:\Downloads\data-team\server-ca.pem";
myBuilder.SslMode = MySqlSslMode.VerifyFull;
// don't set these:
// myBuilder.SslKey = @"G:\Downloads\data-team\client-key.pem";
// myBuilder.SslCert = @"G:\Downloads\data-team\client-cert.pem";
using var myConn = new MySqlConnection(myBuilder.ConnectionString);
// do this instead:
myConn.ProvideClientCertificatesCallback = collection =>
{
var certificate = X509Certificate2.CreateFromPemFile(@"G:\Downloads\data-team\client-cert.pem", @"G:\Downloads\data-team\client-key.pem");
collection.Add(new X509Certificate2(certificate.Export(X509ContentType.Pkcs12)));
return default;
};
myConn.Open(); |
Seems like ProvideClientCertificatesCallback has never been invoked... (step-into never touches break point inside it) |
In order for |
After removing path from connection string, callback works. Thank you so much!!! |
I thought of another workaround (that may be easier): Use
Connection string becomes: |
Should I close this issue? |
No, I'll close it once the fix is shipped (likely in 2.2.6). |
Fixed in 2.2.6. |
Hey, I came across this issue several times the past days, as I am currently (and still) struggling with the Pomelo.EntityFrameworkCore.MySql package also with Since I am using it in an ASP.NET Core-Web-API project, where the Today, I was playing around with just using MySqlConnector (2.3.1) in a .NET 8 console app and was finally able to connect via crt and key file (the first success past 3 days [thanks for that]). MySqlConnectionStringBuilder mcsb = new MySqlConnectionStringBuilder()
{
Server = "example.org",
Port = 3306,
Database = "dbName",
UserID = "userName",
Password = "abc123",
SslMode = MySqlSslMode.VerifyFull,
SslCa = "CA.crt.pem",
};
MySqlConnectionStringBuilder working = new MySqlConnectionStringBuilder(mcsb.ConnectionString)
{
SslCert = "client.crt.pem",
SslKey = "client.key.pem"
};
MySqlConnectionStringBuilder notWorking = new MySqlConnectionStringBuilder(mcsb.ConnectionString)
{
CertificateFile = "bundle.pfx"
};
using MySqlConnection connection = new MySqlConnection(notWorking.ConnectionString);
connection.Open(); I am running the client on Windows side. |
I followed these steps to generate a new client certificate and key: https://dev.mysql.com/doc/refman/8.0/en/creating-ssl-files-using-openssl.html#creating-ssl-files-using-openssl-unix-command-line. (Using Ubuntu 20.04 under WSL on Windows 10.) I then used the command you provided above to create I had no problem connecting to If you can provide thorough steps to reproduce, or failing certificate files, I can try to investigate further. |
https://decoder.link/converter You could also use this online tool provided by Namecheap to perform the format conversion. |
Software versions
MySqlConnector version: latest git cloned repository
Server type (MySQL, MariaDB, Aurora, etc.) and version: GCS 5.7
.NET version: .NET 7
Describe the bug
Unable to open a connection due to auth issue. "No credentials are available in the security package"
Code sample
Exception
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.Private.CoreLib.dll
The text was updated successfully, but these errors were encountered: