private function verifySignature(Object\JWSInterface $jws, Object\JWKSetInterface $jwk_set, Object\SignatureInterface $signature, $detached_payload = null)
{
$input = $this->getInputToVerify($jws, $signature, $detached_payload);
foreach ($jwk_set->getKeys() as $jwk) {
$algorithm = $this->getAlgorithm($signature);
try {
$this->checkKeyUsage($jwk, 'verification');
$this->checkKeyAlgorithm($jwk, $algorithm->getAlgorithmName());
if (true === $algorithm->verify($jwk, $input, $signature->getSignature())) {
return true;
}
} catch (\Exception $e) {
//We do nothing, we continue with other keys
continue;
}
}
return false;
}