SSL connections with MySQL
Posted: 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
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