Skip to content

Commit 0e911d6

Browse files
committed
delay creation of the cert bundle
fixes #18148 Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 6b97f6a commit 0e911d6

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

lib/private/Files/Storage/DAV.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
namespace OC\Files\Storage;
3535

3636
use Exception;
37-
use GuzzleHttp\Exception\RequestException;
3837
use Icewind\Streams\CallbackWrapper;
3938
use Icewind\Streams\IteratorDirectory;
4039
use OC\Files\Filesystem;
@@ -45,6 +44,8 @@
4544
use OCP\Files\ForbiddenException;
4645
use OCP\Files\StorageInvalidException;
4746
use OCP\Files\StorageNotAvailableException;
47+
use OCP\Http\Client\IClientService;
48+
use OCP\ICertificateManager;
4849
use OCP\ILogger;
4950
use OCP\Util;
5051
use Psr\Http\Message\ResponseInterface;
@@ -79,8 +80,10 @@ class DAV extends Common {
7980
protected $client;
8081
/** @var ArrayCache */
8182
protected $statCache;
82-
/** @var \OCP\Http\Client\IClientService */
83+
/** @var IClientService */
8384
protected $httpClientService;
85+
/** @var ICertificateManager */
86+
protected $certManager;
8487

8588
/**
8689
* @param array $params
@@ -111,13 +114,9 @@ public function __construct($params) {
111114
}
112115
if ($this->secure === true) {
113116
// inject mock for testing
114-
$certManager = \OC::$server->getCertificateManager();
115-
if (is_null($certManager)) { //no user
116-
$certManager = \OC::$server->getCertificateManager(null);
117-
}
118-
$certPath = $certManager->getAbsoluteBundlePath();
119-
if (file_exists($certPath)) {
120-
$this->certPath = $certPath;
117+
$this->certManager = \OC::$server->getCertificateManager();
118+
if (is_null($this->certManager)) { //no user
119+
$this->certManager = \OC::$server->getCertificateManager(null);
121120
}
122121
}
123122
$this->root = $params['root'] ?? '/';
@@ -150,8 +149,15 @@ protected function init() {
150149

151150
$this->client = new Client($settings);
152151
$this->client->setThrowExceptions(true);
153-
if ($this->secure === true && $this->certPath) {
154-
$this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
152+
153+
if($this->secure === true) {
154+
$certPath = $this->certManager->getAbsoluteBundlePath();
155+
if (file_exists($certPath)) {
156+
$this->certPath = $certPath;
157+
}
158+
if ($this->certPath) {
159+
$this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
160+
}
155161
}
156162
}
157163

0 commit comments

Comments
 (0)