Using MySQL connector version 8.0.18 I am trying to connect to database using SSL certificates.
I am unable to do so, because this code:
MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
builder.Server = "server";
builder.Port = 3307;
builder.Database = "databse";
builder.UserID = "user";
builder.Password = "************";
builder.SslMode = MySqlSslMode.Required;
builder.SslCa = "ca.pem";
builder.SslCert = "client-cert.pem";
builder.SslKey = "client-key.pem";
MySqlConnection conn = new MySqlConnection(builder.ToString());
conn.Open();
Throws following exception:
MySql.Data.MySqlClient.MySqlException: 'Authentication to host 's-ce.srv.rxe.pl' for user 's-ce.client' using method 'mysql_native_password' failed with message: Access denied for user 'user'@'server' (using password: YES)'
I have put files ca.pem, client-cert.pem and client-key.pem in the same directory where app executable is.
Using MySQL Workbench I was able to connect to this database with same parameters and pem files from the same PC.
What gives?
UPDATE
As advised in comments, I have converted PEM files to single PFX certificate with password of choice. I was able to connect updating code (only relevant changed lines):
builder.SslMode = MySqlSslMode.Required;
builder.CertificateFile = "client-cert.pfx";
builder.CertificatePassword = "************";
MySqlConnection conn = new MySqlConnection(builder.ToString());
MySqlConnectionStringBuilder? Check this stackoverflow.com/questions/39031412/…