return false;
}
+ $hasGoodSignedContent = false;
+
// Check the digest when it is part of the signed data
- if (in_array('digest', $sig_block['headers'])) {
+ if (!empty($content) && in_array('digest', $sig_block['headers'])) {
$digest = explode('=', $headers['digest'], 2);
if ($digest[0] === 'SHA-256') {
$hashalg = 'sha256';
if (!empty($hashalg) && base64_encode(hash($hashalg, $content, true)) != $digest[1]) {
return false;
}
+
+ $hasGoodSignedContent = true;
}
// Check if the signed date field is in an acceptable range
Logger::log("Header date '" . $headers['date'] . "' is with " . $diff . " seconds out of the 300 second frame. The signature is invalid.");
return false;
}
+ $hasGoodSignedContent = true;
}
// Check the content-length when it is part of the signed data
}
}
+ // Ensure that the authentication had been done with some content
+ // Without this check someone could authenticate with fakeable data
+ if (!$hasGoodSignedContent) {
+ return false;
+ }
+
return $key['url'];
}