I am working on a mysql++ application which has to connect to a MySQL
server. I would like to use SSL secured connections but I get an SSL
connection error and I can't find out why. Here is how I am doing it :
First of all, I'am working on Windows XP and Visual C++ 2005. I use MySQL
5.0.27 and mysql++ 2.2.0
I started by creating my certs with OpenSSL 0.9.8d.
Then, I configured the MySQL server by modifying the my.ini file like this :
ssl-ca = "E:/SSL/cacert.pem"
ssl-capath = "E:/SSL/newcerts/"
ssl-cert = "E:/SSL/client-cert.pem"
ssl-key = "E:/SSL/client-key.pem"
ssl-cipher = ALL
# The TCP/IP Port the MySQL Server will listen on
ssl-ca = "D:/MySQL/SSL/cacert.pem"
ssl-capath = "D:/MySQL/SSL/newcerts/"
ssl-cert = "D:/MySQL/SSL/server-cert.pem"
ssl-key = "D:/MySQL/SSL/server-key.pem"
ssl-cipher = ALL
I created an account with the GRANT ... REQUIRE SSL command
I tried to connect with MySQL client :
mysql -u Fred -ppassword --ssl and no problem
I checked the ssl variables, and again no problem, everything is ok
Then I tried to connect the server through my application :
bool ConnectDB( Connection &connection, const char * pNameDB, const char *
pHost, const char * pUser, const char * pPassword )
int iPort = 3306;
unsigned int iClientFlag = CLIENT_SSL;
const char * pKey = "..\\SSL\\client-key.pem";
const char * pCert = "..\\SSL\\client-cert.pem";
const char * pCA = "..\\SSL\\cacert.pem";
const char * pCApath = "..\\SSL\\newcerts\\";
const char * pCipher = "ALL";
connection.enable_ssl( pKey, pCert, pCA, pCApath, pCipher );
connection.connect( pNameDB, pHost, pUser, pPassword, iPort, 0, 60, 0,
catch ( ConnectionFailed error )
cout << "ConnectDB() failed" << endl;
cout << "erreur connection :" << error.what() << endl;
cout << "num err :" << connection.errnum() << endl;
This code always give me the SSL connection error, I tried to give absolute
and relative paths for the certs files, I tried to use the set_option()
function to activate opt_secure_auth option but this function returned
Could anyone tell me what's wrong ?!!
Thanks in advance and sorry for my english which is certainly not
perfect....just like my code ;)
Personnalisez votre Messenger avec Live.com