3

I'm connecting to a MySQL server that requires SSL, using a MySqlConnection:

var connection = new MySqlConnection("Data Source=127.0.0.1;Database=MyDb1;User Id=root;Password=blabla;encrypt=true");

This succeeds if the server doesn't require SSL, but after executing GRANT USAGE ON *.* TO 'root'@'localhost' REQUIRE SSL; on the server, it starts failing with:

ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> MySql.Data.MySqlClient.MySqlException: Authentication to host '127.0.0.1' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'localhost' (using password: YES) ---> MySql.Data.MySqlClient.MySqlException: Access denied for user 'root'@'localhost' (using password: YES)

How is SSL enabled? Should something be added to the connection string or is it done programmatically?

sashoalm
  • 75,001
  • 122
  • 434
  • 781

4 Answers4

5

OK, after some more searching I found the answer at How determine if using SSL in a MySql Connection?.

I had to add SSL Mode=Required instead of encrypt=true to the connection string:

var connection = new MySqlConnection("Data Source=127.0.0.1;Database=MyDb1;User Id=root;Password=blabla;SSL Mode=Required");

Now I'm getting a new error - MySql.Data.MySqlClient.MySqlException: “The host localhost does not support SSL connections.”, but I think I'll figure it out.

sashoalm
  • 75,001
  • 122
  • 434
  • 781
-2

var connection = new MySqlConnection("Data Source=127.0.0.1;Database=MyDb1;User Id=root;Password=blabla;SSL Mode=None");

For me Working Fine...

  • 4
    For anyone looking for an answer to this question, this is not it. As you can see, the question is how to use SSL, not how to disable it. – Camway Feb 18 '21 at 21:33
  • 1
    Scary how this is positioned at the top, when it simply ignores SSL – Daniel Wu Dec 03 '21 at 02:31
-2

You can use this in your connection string.

 SSL Mode=0
Adrian
  • 1
-2

You can try with another user like 'User1@%' or 'User1@192.168.x.x' I hope that can help you

NONABA
  • 1
  • 1
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Pashyant Srivastava Jul 22 '22 at 09:18