From d081aa078489d74b39024745751714876d3716b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sun, 23 Feb 2014 10:47:36 +0000 Subject: [PATCH] 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. --- src/Composer/Command/SelfUpdateCommand.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 3782a5c62..8c300e117 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -56,9 +56,18 @@ EOT protected function execute(InputInterface $input, OutputInterface $output) { - $baseUrl = (extension_loaded('openssl') ? 'https' : 'http') . '://' . self::HOMEPAGE; - $remoteFilesystem = new RemoteFilesystem($this->getIO()); $config = Factory::createConfig(); + if (!extension_loaded('openssl')) { + $output->writeln('The openssl extension is required for SSL/TLS protection.'); + $output->writeln('You can disable this error, at your own risk, by setting the \'disable-tls\' option to "false".'); + return 1; + } elseif($config->get('disable-tls') === true) { + $output->writeln('You are running Composer with SSL/TLS protection disabled.'); + $baseUrl = 'http://' . self::HOMEPAGE; + } else { + $baseUrl = 'https://' . self::HOMEPAGE; + } + $remoteFilesystem = new RemoteFilesystem($this->getIO()); $cacheDir = $config->get('cache-dir'); $rollbackDir = $config->get('home'); $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];