From 474cc9c1edd3d85130976cc6fd6315000f23b5d0 Mon Sep 17 00:00:00 2001 From: Georg Steltner Date: Mon, 20 Jun 2016 15:01:08 +0200 Subject: [PATCH 1/3] don't show error while using ec key --- src/JWT.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JWT.php b/src/JWT.php index 0e613688..6ecccf0b 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -193,7 +193,7 @@ public static function sign($msg, $key, $alg = 'HS256') return hash_hmac($algorithm, $msg, $key, true); case 'openssl': $signature = ''; - $success = openssl_sign($msg, $signature, $key, $algorithm); + $success = @openssl_sign($msg, $signature, $key, $algorithm); if (!$success) { throw new DomainException("OpenSSL unable to sign data"); } else { From 5914102d33ac9b5a2ec698955e8cfbf6cede114a Mon Sep 17 00:00:00 2001 From: Georg Steltner Date: Mon, 20 Jun 2016 15:02:38 +0200 Subject: [PATCH 2/3] don' use openssl_verify while using any php version under 5.4 - its not supported for ec keys --- src/JWT.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/JWT.php b/src/JWT.php index 6ecccf0b..57ae1af4 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -224,6 +224,11 @@ private static function verify($msg, $signature, $key, $alg) list($function, $algorithm) = self::$supported_algs[$alg]; switch($function) { case 'openssl': + // @TODO there is a problem with ec keys, see here for openssl_sign(): + // https://bugs.php.net/bug.php?id=66501 + if (!version_compare(PHP_VERSION, '5.4.0', '>=')) { + throw new Exception('Key type not supported in this PHP build!'); + } $success = openssl_verify($msg, $signature, $key, $algorithm); if (!$success) { throw new DomainException("OpenSSL unable to verify data: " . openssl_error_string()); From 50620eeb077815f7901e3503e863a8fe5280681c Mon Sep 17 00:00:00 2001 From: Georg Steltner Date: Mon, 20 Jun 2016 15:03:36 +0200 Subject: [PATCH 3/3] add necessary use - docs --- src/JWT.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/JWT.php b/src/JWT.php index 57ae1af4..4709acd1 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -1,10 +1,12 @@