]> source.dussan.org Git - nextcloud-server.git/commitdiff
delay creation of the cert bundle 18190/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 28 Nov 2019 12:56:35 +0000 (13:56 +0100)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Mon, 2 Dec 2019 13:33:57 +0000 (14:33 +0100)
fixes #18148

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
lib/private/Files/Storage/DAV.php

index c4ebb0a44dc5d9a5cbc82f668238bef92c587448..c32ec1c1894544a9ddbf2a4599be82a68f625e4b 100644 (file)
@@ -34,7 +34,6 @@
 namespace OC\Files\Storage;
 
 use Exception;
-use GuzzleHttp\Exception\RequestException;
 use OCP\ILogger;
 use Psr\Http\Message\ResponseInterface;
 use Icewind\Streams\CallbackWrapper;
@@ -46,6 +45,8 @@ use OCP\Constants;
 use OCP\Files\FileInfo;
 use OCP\Files\StorageInvalidException;
 use OCP\Files\StorageNotAvailableException;
+use OCP\Http\Client\IClientService;
+use OCP\ICertificateManager;
 use OCP\Util;
 use Sabre\DAV\Client;
 use Sabre\DAV\Xml\Property\ResourceType;
@@ -78,8 +79,10 @@ class DAV extends Common {
        protected $client;
        /** @var ArrayCache */
        protected $statCache;
-       /** @var \OCP\Http\Client\IClientService */
+       /** @var IClientService */
        protected $httpClientService;
+       /** @var ICertificateManager */
+       protected $certManager;
 
        /**
         * @param array $params
@@ -110,13 +113,9 @@ class DAV extends Common {
                        }
                        if ($this->secure === true) {
                                // inject mock for testing
-                               $certManager = \OC::$server->getCertificateManager();
-                               if (is_null($certManager)) { //no user
-                                       $certManager = \OC::$server->getCertificateManager(null);
-                               }
-                               $certPath = $certManager->getAbsoluteBundlePath();
-                               if (file_exists($certPath)) {
-                                       $this->certPath = $certPath;
+                               $this->certManager = \OC::$server->getCertificateManager();
+                               if (is_null($this->certManager)) { //no user
+                                       $this->certManager = \OC::$server->getCertificateManager(null);
                                }
                        }
                        $this->root = $params['root'] ?? '/';
@@ -149,8 +148,15 @@ class DAV extends Common {
 
                $this->client = new Client($settings);
                $this->client->setThrowExceptions(true);
-               if ($this->secure === true && $this->certPath) {
-                       $this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
+
+               if($this->secure === true) {
+                       $certPath = $this->certManager->getAbsoluteBundlePath();
+                       if (file_exists($certPath)) {
+                               $this->certPath = $certPath;
+                       }
+                       if ($this->certPath) {
+                               $this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
+                       }
                }
        }