Add key fingerprints for easier comparison and debugging via diagnose
parent
a9be7c83f1
commit
3ef22258e5
|
@ -22,6 +22,7 @@ use Composer\Util\ConfigValidator;
|
|||
use Composer\Util\ProcessExecutor;
|
||||
use Composer\Util\RemoteFilesystem;
|
||||
use Composer\Util\StreamContextFactory;
|
||||
use Composer\Util\Keys;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
@ -133,6 +134,9 @@ EOT
|
|||
$io->write('Checking disk free space: ', false);
|
||||
$this->outputResult($this->checkDiskSpace($config));
|
||||
|
||||
$io->write('Checking pubkeys: ', false);
|
||||
$this->outputResult($this->checkPubKeys($config));
|
||||
|
||||
$io->write('Checking composer version: ', false);
|
||||
$this->outputResult($this->checkVersion());
|
||||
|
||||
|
@ -327,6 +331,35 @@ EOT
|
|||
return true;
|
||||
}
|
||||
|
||||
private function checkPubKeys($config)
|
||||
{
|
||||
$home = $config->get('home');
|
||||
$errors = [];
|
||||
$io = $this->getIO();
|
||||
|
||||
if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
|
||||
$io->write('');
|
||||
}
|
||||
|
||||
if (file_exists($home.'/keys.tags.pub')) {
|
||||
$io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
|
||||
} else {
|
||||
$errors[] = '<error>Missing pubkey for tags verification</error>';
|
||||
}
|
||||
|
||||
if (file_exists($home.'/keys.dev.pub')) {
|
||||
$io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
|
||||
} else {
|
||||
$errors[] = '<error>Missing pubkey for dev verification</error>';
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
$errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
|
||||
}
|
||||
|
||||
return $errors ?: true;
|
||||
}
|
||||
|
||||
private function checkVersion()
|
||||
{
|
||||
$protocol = extension_loaded('openssl') ? 'https' : 'http';
|
||||
|
|
|
@ -16,6 +16,7 @@ use Composer\Composer;
|
|||
use Composer\Factory;
|
||||
use Composer\Config;
|
||||
use Composer\Util\Filesystem;
|
||||
use Composer\Util\Keys;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Util\RemoteFilesystem;
|
||||
use Composer\Downloader\FilesystemException;
|
||||
|
@ -220,7 +221,8 @@ EOT
|
|||
}
|
||||
}
|
||||
}
|
||||
file_put_contents($config->get('home').'/keys.dev.pub', $match[0]);
|
||||
file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
|
||||
$io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
|
||||
|
||||
$tagsKey = '';
|
||||
while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
|
||||
|
@ -232,7 +234,8 @@ EOT
|
|||
}
|
||||
}
|
||||
}
|
||||
file_put_contents($config->get('home').'/keys.tags.pub', $match[0]);
|
||||
file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
|
||||
$io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
|
||||
|
||||
$io->write('Public keys stored in '.$config->get('home'));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue