diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php
index e95ca8eaa..cbd4a7c60 100644
--- a/src/Composer/Command/DiagnoseCommand.php
+++ b/src/Composer/Command/DiagnoseCommand.php
@@ -117,6 +117,25 @@ EOT
$io->write('Checking https connectivity to packagist: ', false);
$this->outputResult($this->checkHttp('https', $config));
+ foreach ($config->getRepositories() as $repo) {
+ if (($repo['type'] ?? null) === 'composer' && isset($repo['url'])) {
+ $composerRepo = new ComposerRepository($repo, $this->getIO(), $config, $this->httpDownloader);
+ $reflMethod = new \ReflectionMethod($composerRepo, 'getPackagesJsonUrl');
+ if (PHP_VERSION_ID < 80100) {
+ $reflMethod->setAccessible(true);
+ }
+ $url = $reflMethod->invoke($composerRepo);
+ if (!str_starts_with($url, 'http')) {
+ continue;
+ }
+ if (str_starts_with($url, 'https://repo.packagist.org')) {
+ continue;
+ }
+ $io->write('Checking connectivity to ' . $repo['url'].': ', false);
+ $this->outputResult($this->checkComposerRepo($url, $config));
+ }
+ }
+
$proxyManager = ProxyManager::getInstance();
$protos = $config->get('disable-tls') === true ? ['http'] : ['http', 'https'];
try {
@@ -310,6 +329,45 @@ EOT
return true;
}
+ /**
+ * @return string|string[]|true
+ */
+ private function checkComposerRepo(string $url, Config $config)
+ {
+ $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
+ if ($result !== true) {
+ return $result;
+ }
+
+ $result = [];
+ if (str_starts_with($url, 'https://') && $config->get('disable-tls') === true) {
+ $tlsWarning = 'Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.';
+ }
+
+ try {
+ $this->httpDownloader->get($url);
+ } catch (TransportException $e) {
+ $hints = HttpDownloader::getExceptionHints($e);
+ if (null !== $hints && count($hints) > 0) {
+ foreach ($hints as $hint) {
+ $result[] = $hint;
+ }
+ }
+
+ $result[] = '[' . get_class($e) . '] ' . $e->getMessage() . '';
+ }
+
+ if (isset($tlsWarning)) {
+ $result[] = $tlsWarning;
+ }
+
+ if (count($result) > 0) {
+ return $result;
+ }
+
+ return true;
+ }
+
/**
* @return string|\Exception
*/