Skip to content

Commit 8abb497

Browse files
committed
:octocat: check cacert realpath
1 parent 4a74356 commit 8abb497

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/HttpFactoryTrait.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface
1818
};
1919
use InvalidArgumentException;
20-
use function class_exists, constant, defined, file_exists, in_array, sprintf;
20+
use function class_exists, constant, defined, file_exists, in_array, realpath, sprintf, trim;
2121

2222
/**
2323
* Invokes a set of PSR-17 HTTP factories and a PSR-18 HTTP client
@@ -72,12 +72,14 @@ protected function initFactories(string $cacert = ''):void{
7272
}
7373

7474
if(isset($this->httpClientFactory)){
75+
$cacert = trim($cacert);
76+
$realpath = realpath($cacert);
7577

76-
if(empty($cacert) || !file_exists($cacert)){
78+
if($cacert === '' || !file_exists($cacert) || $realpath === false){
7779
throw new InvalidArgumentException(sprintf('invalid CA bundle: "%s"', $cacert));
7880
}
7981

80-
$this->httpClient = $this->httpClientFactory->getClient($cacert, $this->responseFactory);
82+
$this->httpClient = $this->httpClientFactory->getClient($realpath, $this->responseFactory);
8183
}
8284
}
8385

0 commit comments

Comments
 (0)