You are here

public function Verifier::verifyCsigChecksumFile in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/drupal/php-signify/src/Verifier.php \Drupal\Signify\Verifier::verifyCsigChecksumFile()

Verify the a signed checksum list file, and then verify the checksum for each file in the list.

Parameters

string $checksum_file: The filename of a .csig signed checksum list file.

\DateTime $now: If provided, a \DateTime object modeling "now".

Return value

int The number of files that were successfully verified.

Throws

\SodiumException

\Drupal\Signify\VerifierException Thrown when the checksum list could not be verified by the signature, or a listed file could not be verified.

File

vendor/drupal/php-signify/src/Verifier.php, line 306

Class

Verifier

Namespace

Drupal\Signify

Code

public function verifyCsigChecksumFile($csig_checksum_file, \DateTime $now = NULL) {
  $absolute_path = realpath($csig_checksum_file);
  if (empty($absolute_path)) {
    throw new VerifierException("The real path of checksum list file at \"{$csig_checksum_file}\" could not be determined.");
  }
  $working_directory = dirname($absolute_path);
  if (is_dir($absolute_path)) {
    throw new VerifierException("The checksum list file at \"{$csig_checksum_file}\" is a directory, not a file.");
  }
  $signed_checksum_list = file_get_contents($absolute_path);
  if (empty($signed_checksum_list)) {
    throw new VerifierException("The checksum list file at \"{$csig_checksum_file}\" could not be read.");
  }
  return $this
    ->verifyCsigChecksumList($signed_checksum_list, $working_directory, $now);
}