diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 6c9158630..b7739ff18 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -432,7 +432,11 @@ EOT } $versionsUtil = new Versions($config, $this->rfs); - $latest = $versionsUtil->getLatest(); + try { + $latest = $versionsUtil->getLatest(); + } catch (\Exception $e) { + return $e; + } if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') { return 'You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')'; diff --git a/src/Composer/SelfUpdate/Versions.php b/src/Composer/SelfUpdate/Versions.php index 01d01e7e3..6a0a1bdbf 100644 --- a/src/Composer/SelfUpdate/Versions.php +++ b/src/Composer/SelfUpdate/Versions.php @@ -63,7 +63,12 @@ class Versions public function getLatest($channel = null) { - $protocol = extension_loaded('openssl') ? 'https' : 'http'; + if ($this->config->get('disable-tls') === true) { + $protocol = 'http'; + } else { + $protocol = 'https'; + } + $versions = JsonFile::parseJson($this->rfs->getContents('getcomposer.org', $protocol . '://getcomposer.org/versions', false)); foreach ($versions[$channel ?: $this->getChannel()] as $version) {