public function validateSignature($certificates)
{
foreach ($certificates as $cert) {
assert('is_string($cert)');
$certFile = \SimpleSAML\Utils\Config::getCertPath($cert);
if (!file_exists($certFile)) {
throw new Exception('Could not find certificate file [' . $certFile . '], which is needed to validate signature');
}
$certData = file_get_contents($certFile);
foreach ($this->validators as $validator) {
$key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'public'));
$key->loadKey($certData);
try {
if ($validator->validate($key)) {
return true;
}
} catch (Exception $e) {
// this certificate did not sign this element, skip
}
}
}
SimpleSAML\Logger::debug('Could not validate signature');
return false;
}