You are here

protected function InPlaceUpdate::validateArchive in Automatic Updates 8

Validate the downloaded archive.

Parameters

string $directory: The location of the downloaded archive.

string $csig: The CSIG contents.

Throws

\SodiumException

1 call to InPlaceUpdate::validateArchive()
InPlaceUpdate::getArchive in src/Services/InPlaceUpdate.php
Get an archive with the quasi-patch contents.

File

src/Services/InPlaceUpdate.php, line 353

Class

InPlaceUpdate
Class to apply in-place updates.

Namespace

Drupal\automatic_updates\Services

Code

protected function validateArchive($directory, $csig) {
  $module_path = drupal_get_path('module', 'automatic_updates');
  $key = file_get_contents($module_path . '/artifacts/keys/root.pub');
  $verifier = new Verifier($key);
  $files = $verifier
    ->verifyCsigMessage($csig);
  $checksums = new ChecksumList($files, TRUE);
  $failed_checksums = new FailedCheckumFilter($checksums, $directory);
  if (iterator_count($failed_checksums)) {
    throw new \RuntimeException('The downloaded files did not match what was expected.');
  }
}