SSL connections with MySQL

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
techguy76
Posts: 3
Joined: Fri 13 Mar 2009 20:02

SSL connections with MySQL

Post by techguy76 » Fri 13 Mar 2009 20:16

hi, I am having trouble using dotConnect version 5.0.22 in a C# application using SSL to connect to a server using MySQL version 5.1.17 (windows). I first experienced problems using a licensed version of MySqlDirect version 3.50.13, but tried downloading a trial of the latest version, and it still didn't work.

Some information that might help:
1. If I use the same parameters without the SSL-related parts, I'm able to connect, but once I enable SSL, it fails the connection.
2. There is nothing wrong with the .pem files because I can use mysql.exe to connect, and "show status like '%ssl'" confirms that SSL is enabled.
3. The MySql server is not on the same machine as the C# client.

Here is the MySqlConnection.ConnectionString property before calling Open():
"User Id=user;Password=password;Host=192.168.0.4;Port=5555;Database=testdb;Protocol=Ssl;SSL CA Cert=file://C:/Test/cacert.pem;SSL Cert=file://C:/Test/cert.pem;SSL Key=file://C:/Test/key.pem;"

Here is the exception text:
"Lost connection to MySQL server during query."

Here is the Stack Trace:
"at Devart.Data.MySql.af.d(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.MySql.af.j()
at Devart.Data.MySql.s.a(String A_0, String A_1, String A_2, String A_3, Int32 A_4, String A_5, Int32 A_6, SshOptions A_7, SslOptions A_8, ProxyOptions A_9, HttpOptions A_10)
at Devart.Data.MySql.MySqlInternalConnection.Connect(String userId, String password, String host, String database, Int32 port, Int32 connectionTimeout, MySqlProtocol protocol, Boolean compress, Boolean clientInteractive)
at Devart.Data.MySql.MySqlInternalConnection..ctor(o connectionOptions)
at Devart.Data.MySql.ao.a(p A_0, Object A_1, DbConnectionBase A_2)
at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, p A_1)
at Devart.Common.DbConnectionPool.a()
at Devart.Common.DbConnectionPool.GetObject()
at Devart.Common.DbConnectionFactory.a(DbConnectionBase A_0)
at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
at Devart.Data.MySql.MySqlConnection.Open()
at Tester.Connect()"

There was nothing in exception.InnerException.

And here is the command-line input to mysql.exe that works:
"D:\mysql\bin> mysql -u user -ppassword -P5555 -h192.168.0.4 --ssl-ca=c:\Test\cacert.pem --ssl-cert=c:\Test\cert.pem --ssl-key=c:\Test\key.pem"


any help would be greatly appreciated.

Jake Chung

techguy76
Posts: 3
Joined: Fri 13 Mar 2009 20:02

Post by techguy76 » Mon 16 Mar 2009 18:43

I don't know why this matters....but I didn't mention that the CLIENT was running on a windows 2003 server, while the MySQL server is running on a windows XP pro server.

When I installed the client on a windows XP server, the app ran fine without those connection errors. I checked the .NET framework versions on the two client machines, and they were the same - 2.0.50727.

Does anyone have any ideas on what could be wrong?

techguy76
Posts: 3
Joined: Fri 13 Mar 2009 20:02

Problem fixed

Post by techguy76 » Tue 17 Mar 2009 13:14

I was able to resolve my problem, and I just wanted to post the solution in case someone else runs into the same problem.

SSL 2.0 was disabled on the windows 2003 machine, while SSL 3.0 was enabled. I guess dotConnect was trying to use SSL 3.0 to connect to my database server, which is not compatible?

Anyway, once I enabled SSL 2.0, my app started working. The option to enable/disable SSL 2.0 or 3.0 is in....
1. Control Panel>Internet Options.
2. Advanced Tab.
3. Scroll almost all the way to the bottom, and you'll see a checkbox for "Use SSL 2.0" and "Use SSL 3.0". Make sure the first one is checked.
4. Click 'Apply'

What is weird is that when I tried to reproduce my failure case by disabling SSL 2.0 again, it continued to successfully make connections to my database server....

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 18 Mar 2009 07:50

dotConnect for MySQL uses SSL 3.0. Probably, the problem was in the settings of your Windows Server 2003, but we cannot tell you for sure the exact reason. Please refer to the appropriate documentation: http://technet.microsoft.com/en-us/libr ... 81800.aspx .

Post Reply