0

I am getting this error while trying to connect mysql on SSL.

Warning: mysqli_real_connect() [function.mysqli-real-connect]: SSL operation failed with code 1. OpenSSL Error messages: error:14082174:SSL routines:SSL3_CHECK_CERT_AND_ALGORITHM:dh key too small in /usr/www/test/testing.php on line 13

This works fine on my local wamp or xampp but not on the hosting web server

What can be done to solve this ? Any help will be appreciated.

After Notes -

I was originally using

$db->ssl_set('client-key.pem', 'client-cert.pem', 'ca-cert.pem', NULL, 'NULL');

and it used to work fine for years but only after we upgraded to different SSL certs it stopped working.

It should be what Mel_T just answered..

Dev
  • 113
  • 1
  • 2
  • 13
  • http://stackoverflow.com/questions/30701397/ssl-operation-failed-with-code-1-dh-key-too-small might be helpful – theduck Jul 06 '15 at 14:46
  • I read that post but it did not help why local server would work okay. This connection would work okay some time back but started showing this error recently. – Dev Jul 06 '15 at 14:56

1 Answers1

2

You have to put a cipher in your mysqli connection, see http://php.net/manual/de/mysqli.ssl-set.php

$db = mysqli_init(); 
mysqli_options($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);

$db->ssl_set('/etc/mysql/certs/client-key.pem', '/etc/mysql/certs/client-cert.pem', '/etc/mysql/certs/ca-cert.pem', NULL, 'CAMELLIA128-SHA'); 
$link = mysqli_real_connect ($db, 'host', 'user', 'password', 'mysql', 'port', NULL, MYSQLI_CLIENT_SSL);
Mel_T
  • 451
  • 5
  • 15