Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use fixed CN_match for github hosts, fixes #4782
  • Loading branch information
Seldaek committed Jan 17, 2016
1 parent 42f49b3 commit 8375af2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Composer/Util/RemoteFilesystem.php
Expand Up @@ -143,7 +143,7 @@ public function getLastHeaders()
*
* @return bool|string
*/
protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true, $expectedCommonName = '')
protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
{
if (strpos($originUrl, '.github.com') === (strlen($originUrl) - 11)) {
$originUrl = 'github.com';
Expand All @@ -170,7 +170,7 @@ protected function get($originUrl, $fileUrl, $additionalOptions = array(), $file
unset($additionalOptions['retry-auth-failure']);
}

$options = $this->getOptionsForUrl($originUrl, $additionalOptions, $expectedCommonName);
$options = $this->getOptionsForUrl($originUrl, $additionalOptions);

if ($this->io->isDebug()) {
$this->io->writeError((substr($fileUrl, 0, 4) === 'http' ? 'Downloading ' : 'Reading ') . $fileUrl);
Expand Down Expand Up @@ -319,7 +319,7 @@ protected function get($originUrl, $fileUrl, $additionalOptions = array(), $file
if ($this->retry) {
$this->retry = false;

$result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress, $expectedCommonName);
$result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);

$authHelper = new AuthHelper($this->io, $this->config);
$authHelper->storeAuth($this->originUrl, $this->storeAuth);
Expand All @@ -329,7 +329,7 @@ protected function get($originUrl, $fileUrl, $additionalOptions = array(), $file
}

if (false === $result) {
$e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage.' using CN='.$expectedCommonName, $errorCode);
$e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
if (!empty($http_response_header[0])) {
$e->setHeaders($http_response_header);
}
Expand Down Expand Up @@ -484,6 +484,10 @@ protected function getOptionsForUrl($originUrl, $additionalOptions)
$host = parse_url($this->fileUrl, PHP_URL_HOST);
}

if ($host === 'github.com' || $host === 'api.github.com') {
$host = '*.github.com';
}

$tlsOptions['ssl']['CN_match'] = $host;
$tlsOptions['ssl']['SNI_server_name'] = $host;
}
Expand Down

0 comments on commit 8375af2

Please sign in to comment.