dont rewrite temp CA file if it already exists
and make it readable by everyone the first time we create itpull/4805/head
parent
1adb2e6005
commit
cef97904d0
|
@ -633,10 +633,15 @@ class RemoteFilesystem
|
||||||
*/
|
*/
|
||||||
if (!isset($defaults['ssl']['cafile'], $defaults['ssl']['capath'])) {
|
if (!isset($defaults['ssl']['cafile'], $defaults['ssl']['capath'])) {
|
||||||
$result = $this->getSystemCaRootBundlePath();
|
$result = $this->getSystemCaRootBundlePath();
|
||||||
if ($result) {
|
|
||||||
if (preg_match('{^phar://}', $result)) {
|
|
||||||
$targetPath = rtrim(sys_get_temp_dir(), '\\/') . '/composer-cacert.pem';
|
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
throw new TransportException('A valid cafile or capath could not be located automatically.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('{^phar://}', $result)) {
|
||||||
|
$targetPath = rtrim(sys_get_temp_dir(), '\\/') . '/composer-cacert.pem';
|
||||||
|
|
||||||
|
if (!file_exists($targetPath)) {
|
||||||
// use stream_copy_to_stream instead of copy
|
// use stream_copy_to_stream instead of copy
|
||||||
// to work around https://bugs.php.net/bug.php?id=64634
|
// to work around https://bugs.php.net/bug.php?id=64634
|
||||||
$source = fopen($result, 'r');
|
$source = fopen($result, 'r');
|
||||||
|
@ -644,18 +649,15 @@ class RemoteFilesystem
|
||||||
stream_copy_to_stream($source, $target);
|
stream_copy_to_stream($source, $target);
|
||||||
fclose($source);
|
fclose($source);
|
||||||
fclose($target);
|
fclose($target);
|
||||||
|
chmod($targetPath, 0744);
|
||||||
unset($source, $target);
|
unset($source, $target);
|
||||||
|
|
||||||
$defaults['ssl']['cafile'] = $targetPath;
|
|
||||||
} else {
|
|
||||||
if (is_dir($result)) {
|
|
||||||
$defaults['ssl']['capath'] = $result;
|
|
||||||
} elseif ($result) {
|
|
||||||
$defaults['ssl']['cafile'] = $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$defaults['ssl']['cafile'] = $targetPath;
|
||||||
|
} elseif (is_dir($result)) {
|
||||||
|
$defaults['ssl']['capath'] = $result;
|
||||||
} else {
|
} else {
|
||||||
throw new TransportException('A valid cafile or capath could not be located automatically.');
|
$defaults['ssl']['cafile'] = $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue