Skip to content

Commit

Permalink
Raise exception when openssl_sign() call fails
Browse files Browse the repository at this point in the history
Fixes: #132
  • Loading branch information
lcobucci committed Oct 31, 2016
1 parent 0bcd321 commit ddce703
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Signer/Rsa.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -47,8 +52,6 @@ public function doVerify($expected, $payload, Key $key)
*
* @param resource $key
*
* @return boolean
*
* @throws InvalidArgumentException
*/
private function validateKey($key)
Expand Down

0 comments on commit ddce703

Please sign in to comment.