PHP Error:0607A082:digital envelope routines:EVP_CI PHER_CTX_set_key_length:invalid key length

If you are trying to use and older version of PHP to connect MYSQL over SSL, there is a good chance that you encounter the following errors:
error:0607A082:digital envelope routines:EVP_CI PHER_CTX_set_key_length:
error:0906D06C:PEM routines:PEM_read_bio:no start line

This is a bug in PHP, OpenSSL. This bug has been fixed in PHP versions > 7.1.

In case you are stuck with the older version of the PHP, here is a workaround:
You will need to add the following line before any prepare/query command.


This will clear the previous openssl error.
Usage Eg:

$db->prepare('SELECT * from test');
$db->query('SELECT * from test');

Hope this helps.

Leave a comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.