From ddce703826f9c5229781933b1a39069e38e6a0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Mon, 31 Oct 2016 20:09:32 +0000 Subject: [PATCH] Raise exception when openssl_sign() call fails Fixes: https://github.com/lcobucci/jwt/issues/132 --- src/Signer/Rsa.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Signer/Rsa.php b/src/Signer/Rsa.php index a89ff456..0db19c57 100644 --- a/src/Signer/Rsa.php +++ b/src/Signer/Rsa.php @@ -26,7 +26,12 @@ public function createHash($payload, Key $key) $this->validateKey($key); $signature = ''; - openssl_sign($payload, $signature, $key, $this->getAlgorithm()); + + if (!openssl_sign($payload, $signature, $key, $this->getAlgorithm())) { + throw new InvalidArgumentException( + 'There was an error while creating the signature: ' . openssl_error_string() + ); + } return $signature; } @@ -47,8 +52,6 @@ public function doVerify($expected, $payload, Key $key) * * @param resource $key * - * @return boolean - * * @throws InvalidArgumentException */ private function validateKey($key)