Problem with connecting to MySql using SSL
Hi,
I am trying to connect MySql database using an SSL connection. Connecting without SSL works fine.
I created a database and a user with REQUIRE SSL option. When I try to connect I get: "SSL connection error QMYSQL: Unable to connect".
I am using Qt 4.7 64 bit on Ubuntu 10.04
The code looks like the following:
Code:
if (!db.isValid())
{
return;
}
db.setDatabaseName(dbName);
db.setHostName("localhost");
db.setPort(3306);
db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1");
if (!db.open(userName, password))
{
qDebug()<<db.lastError().text();
return;
}
Was anyone able to work using this setup before?
Thank you
Re: Problem with connecting to MySql using SSL
I guess you have to configure server to support SSL (SSL permission on account, ciphers, certificate,etc.). You can read more here http://dev.mysql.com/doc/refman/5.0/...nnections.html
Re: Problem with connecting to MySql using SSL
In the other hand, client-side shoud be set up too :
Code:
db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1");
if (v.isValid() && qstrcmp(v.typeName(), "MYSQL*")==0)
{
MYSQL *handle = static_cast<MYSQL *>(v.data());
if (handle != NULL)
{
mysql_ssl_set(handle, "./ssl/client-key.pem",
"./ssl/client-cert.pem", "./ssl/cacert.pem",
NULL, NULL);
}
}
db.open();
Refer to mysql_ssl_set() for details.