Skip to content

Commit 2ab1c4d

Browse files
authored
Merge pull request #18187 from nextcloud/backport/18149/stable16
[stable16] delay creation of the cert bundle
2 parents 623776f + 900cd12 commit 2ab1c4d

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 OCP\ILogger;
3938
use Psr\Http\Message\ResponseInterface;
4039
use Icewind\Streams\CallbackWrapper;
@@ -46,6 +45,8 @@
4645
use OCP\Files\FileInfo;
4746
use OCP\Files\StorageInvalidException;
4847
use OCP\Files\StorageNotAvailableException;
48+
use OCP\Http\Client\IClientService;
49+
use OCP\ICertificateManager;
4950
use OCP\Util;
5051
use Sabre\DAV\Client;
5152
use Sabre\DAV\Xml\Property\ResourceType;
@@ -78,8 +79,10 @@ class DAV extends Common {
7879
protected $client;
7980
/** @var ArrayCache */
8081
protected $statCache;
81-
/** @var \OCP\Http\Client\IClientService */
82+
/** @var IClientService */
8283
protected $httpClientService;
84+
/** @var ICertificateManager */
85+
protected $certManager;
8386

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

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

0 commit comments

Comments
 (0)