1
0
Fork 0

Restructure self-update http/https decision

Error on non-openssl and warn user about setting disable-tls to disable error.
If disable-tls is true, ad an info message about running in non-TLS mode.
pull/2745/head
Pádraic Brady 2014-02-23 10:47:36 +00:00
parent 7e30c67827
commit d081aa0784
1 changed files with 11 additions and 2 deletions

View File

@ -56,9 +56,18 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$baseUrl = (extension_loaded('openssl') ? 'https' : 'http') . '://' . self::HOMEPAGE;
$remoteFilesystem = new RemoteFilesystem($this->getIO());
$config = Factory::createConfig(); $config = Factory::createConfig();
if (!extension_loaded('openssl')) {
$output->writeln('<error>The openssl extension is required for SSL/TLS protection.</error>');
$output->writeln('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to "false".</error>');
return 1;
} elseif($config->get('disable-tls') === true) {
$output->writeln('<info>You are running Composer with SSL/TLS protection disabled.</info>');
$baseUrl = 'http://' . self::HOMEPAGE;
} else {
$baseUrl = 'https://' . self::HOMEPAGE;
}
$remoteFilesystem = new RemoteFilesystem($this->getIO());
$cacheDir = $config->get('cache-dir'); $cacheDir = $config->get('cache-dir');
$rollbackDir = $config->get('home'); $rollbackDir = $config->get('home');
$localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0]; $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];