|
|
|
@ -271,16 +271,24 @@ class Checker {
|
|
|
|
|
public function writeAppSignature($path,
|
|
|
|
|
X509 $certificate,
|
|
|
|
|
RSA $privateKey) {
|
|
|
|
|
if(!is_dir($path)) {
|
|
|
|
|
throw new \Exception('Directory does not exist.');
|
|
|
|
|
}
|
|
|
|
|
$appInfoDir = $path . '/appinfo';
|
|
|
|
|
$this->fileAccessHelper->assertDirectoryExists($path);
|
|
|
|
|
$this->fileAccessHelper->assertDirectoryExists($appInfoDir);
|
|
|
|
|
|
|
|
|
|
$iterator = $this->getFolderIterator($path);
|
|
|
|
|
$hashes = $this->generateHashes($iterator, $path);
|
|
|
|
|
$signature = $this->createSignatureData($hashes, $certificate, $privateKey);
|
|
|
|
|
$this->fileAccessHelper->file_put_contents(
|
|
|
|
|
$path . '/appinfo/signature.json',
|
|
|
|
|
try {
|
|
|
|
|
$this->fileAccessHelper->file_put_contents(
|
|
|
|
|
$appInfoDir . '/signature.json',
|
|
|
|
|
json_encode($signature, JSON_PRETTY_PRINT)
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e){
|
|
|
|
|
if (!$this->fileAccessHelper->is_writeable($appInfoDir)){
|
|
|
|
|
throw new \Exception($appInfoDir . ' is not writable');
|
|
|
|
|
}
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -289,17 +297,29 @@ class Checker {
|
|
|
|
|
* @param X509 $certificate
|
|
|
|
|
* @param RSA $rsa
|
|
|
|
|
* @param string $path
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
*/
|
|
|
|
|
public function writeCoreSignature(X509 $certificate,
|
|
|
|
|
RSA $rsa,
|
|
|
|
|
$path) {
|
|
|
|
|
$coreDir = $path . '/core';
|
|
|
|
|
$this->fileAccessHelper->assertDirectoryExists($path);
|
|
|
|
|
$this->fileAccessHelper->assertDirectoryExists($coreDir);
|
|
|
|
|
|
|
|
|
|
$iterator = $this->getFolderIterator($path, $path);
|
|
|
|
|
$hashes = $this->generateHashes($iterator, $path);
|
|
|
|
|
$signatureData = $this->createSignatureData($hashes, $certificate, $rsa);
|
|
|
|
|
$this->fileAccessHelper->file_put_contents(
|
|
|
|
|
$path . '/core/signature.json',
|
|
|
|
|
try {
|
|
|
|
|
$this->fileAccessHelper->file_put_contents(
|
|
|
|
|
$coreDir . '/signature.json',
|
|
|
|
|
json_encode($signatureData, JSON_PRETTY_PRINT)
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e){
|
|
|
|
|
if (!$this->fileAccessHelper->is_writeable($coreDir)){
|
|
|
|
|
throw new \Exception($coreDir . ' is not writable');
|
|
|
|
|
}
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|