From 33bed5d38faa1010b8ae0386fb84bcec7034c40f Mon Sep 17 00:00:00 2001 From: Aruna Lakmal Date: Wed, 22 Jul 2015 14:47:36 +1200 Subject: [PATCH 1/2] clear openssl error stack as this causes to close database connection --- src/JWT.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/JWT.php b/src/JWT.php index ff7c07d4..0189976d 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -208,9 +208,11 @@ private static function verify($msg, $signature, $key, $alg) list($function, $algorithm) = self::$supported_algs[$alg]; switch($function) { case 'openssl': + while ($msg = openssl_error_string()) {} $success = openssl_verify($msg, $signature, $key, $algorithm); + while ($msg = openssl_error_string()) {$msglist[] = $msg;} if (!$success) { - throw new DomainException("OpenSSL unable to verify data: " . openssl_error_string()); + throw new DomainException("OpenSSL unable to verify data: " . implode(',', $msglist)); } else { return $signature; } From 2abf4b431e88336ab189fb86201493b0befb88e5 Mon Sep 17 00:00:00 2001 From: Aruna Lakmal Date: Thu, 23 Jul 2015 09:19:31 +1200 Subject: [PATCH 2/2] fix error in override $msg --- src/JWT.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/JWT.php b/src/JWT.php index 0189976d..9a98cb00 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -208,11 +208,11 @@ private static function verify($msg, $signature, $key, $alg) list($function, $algorithm) = self::$supported_algs[$alg]; switch($function) { case 'openssl': - while ($msg = openssl_error_string()) {} + while ($err = openssl_error_string()) {} $success = openssl_verify($msg, $signature, $key, $algorithm); - while ($msg = openssl_error_string()) {$msglist[] = $msg;} + while ($err = openssl_error_string()) {$errors[] = $err;} if (!$success) { - throw new DomainException("OpenSSL unable to verify data: " . implode(',', $msglist)); + throw new DomainException("OpenSSL unable to verify data: " . implode(',', $errors)); } else { return $signature; }