Correctly report OpenSSL errors from cookie encryption

Without calling openssl_error_string() we pollute openssl global state
and some other library might report this as failure (eg. mysqlnd driver
when connecting to SSL enabled server).

Fixes #12293

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2016-12-20 14:36:25 +01:00
parent b866371b9a
commit 03bc52f6dc
2 changed files with 17 additions and 1 deletions

View File

@ -23,6 +23,7 @@ phpMyAdmin - ChangeLog
- issue #11816 Fixed operation with lower_case_table_names=2
- issue #12813 Fixed stored procedure execution
- issue #12826 Honor user configured connection collation
- issue #12293 Correctly report OpenSSL errors from cookie encryption
4.6.5.2 (2016-12-05)
- issue #12765 Fixed SQL export with newlines

View File

@ -717,6 +717,18 @@ class AuthenticationCookie extends AuthenticationPlugin
);
}
/**
* Reports any SSL errors
*
* @return void
*/
public function reportSSLErrors()
{
while (($ssl_err = openssl_error_string()) !== false) {
trigger_error('OpenSSL error: ' . $ssl_err, E_USER_ERROR);
}
}
/**
* Encryption using openssl's AES or phpseclib's AES
* (phpseclib uses mcrypt when it is available)
@ -739,6 +751,7 @@ class AuthenticationCookie extends AuthenticationPlugin
0,
$iv
);
$this->reportSSLErrors();
} else {
$cipher = new Crypt\AES(Crypt\Base::MODE_CBC);
$cipher->setIV($iv);
@ -783,13 +796,15 @@ class AuthenticationCookie extends AuthenticationPlugin
}
if ($this->_use_openssl) {
return openssl_decrypt(
$result = openssl_decrypt(
$data['payload'],
'AES-128-CBC',
$secret,
0,
base64_decode($data['iv'])
);
$this->reportSSLErrors();
return $result;
} else {
$cipher = new Crypt\AES(Crypt\Base::MODE_CBC);
$cipher->setIV(base64_decode($data['iv']));