You are here

public function Verifier::verifyChecksumFile in Automatic Updates 8

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

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 signed checksum list file.

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 211

Class

Verifier

Namespace

Drupal\Signify

Code

public function verifyChecksumFile($checksum_file) {
  $absolute_path = realpath($checksum_file);
  if (empty($absolute_path)) {
    throw new VerifierException("The real path of checksum list file at \"{$checksum_file}\" could not be determined.");
  }
  $working_directory = dirname($absolute_path);
  if (is_dir($absolute_path)) {
    throw new VerifierException("The checksum list file at \"{$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 \"{$checksum_file}\" could not be read.");
  }
  return $this
    ->verifyChecksumList($signed_checksum_list, $working_directory);
}