]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not read certificate bundle from data dir by default 21090/head
authorMorris Jobke <hey@morrisjobke.de>
Mon, 25 May 2020 13:03:52 +0000 (15:03 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Mon, 25 May 2020 14:57:56 +0000 (16:57 +0200)
Before the resources/config/ca-bundle.crt was only used when the list of custom
certificates was empty and the instance was not installed. But it should also
be used when the list is empty and the instance is installed.

This is inverting the logic to stop if the instance is not installed to use the
default bundle. And it also does this when the list is empty.

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
lib/private/Http/Client/Client.php
tests/lib/Http/Client/ClientTest.php

index af43df6365f8c268ddb2fa786b4d694cd4fa5a13..58234d1653589f1fdca1216303e48a5cbffd71ed 100644 (file)
@@ -97,18 +97,18 @@ class Client implements IClient {
        }
 
        private function getCertBundle(): string {
-               if ($this->certificateManager->listCertificates() !== []) {
-                       return $this->certificateManager->getAbsoluteBundlePath();
-               }
-
                // If the instance is not yet setup we need to use the static path as
                // $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
                // a view
-               if ($this->config->getSystemValue('installed', false)) {
-                       return $this->certificateManager->getAbsoluteBundlePath(null);
+               if ($this->config->getSystemValue('installed', false) === false) {
+                       return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
+               }
+
+               if ($this->certificateManager->listCertificates() === []) {
+                       return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
                }
 
-               return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
+               return $this->certificateManager->getAbsoluteBundlePath();
        }
 
        /**
index a0c4d75c1bd8496f6114a6b3ec548842aa60e775..a462a0848ae7284ac84d5569109ed4175161912e 100644 (file)
@@ -461,9 +461,8 @@ class ClientTest extends \Test\TestCase {
                        ->with('installed', false)
                        ->willReturn(false);
                $this->certificateManager
-                       ->expects($this->once())
-                       ->method('listCertificates')
-                       ->willReturn([]);
+                       ->expects($this->never())
+                       ->method('listCertificates');
 
                $this->assertEquals([
                        'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt',