From b1e9752169e60d0cf894a0d4ebec35ff07f7d70c Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 4 Dec 2020 13:37:10 +0100 Subject: [PATCH] Revert "Do not read certificate bundle from data dir by default" This reverts commit 18b0d753f2d76da10fefbf9a34e22dfdcbdc93b0. --- lib/private/Http/Client/Client.php | 14 +++++++------- tests/lib/Http/Client/ClientTest.php | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index af4ebc5272..eedd34774c 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -98,18 +98,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 instantiate // a view - if ($this->config->getSystemValue('installed', false) === false) { - return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; + if ($this->config->getSystemValue('installed', false)) { + return $this->certificateManager->getAbsoluteBundlePath(null); } - if ($this->certificateManager->listCertificates() === []) { - return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; - } - - return $this->certificateManager->getAbsoluteBundlePath(); + return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; } /** diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index a462a0848a..a0c4d75c1b 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -461,8 +461,9 @@ class ClientTest extends \Test\TestCase { ->with('installed', false) ->willReturn(false); $this->certificateManager - ->expects($this->never()) - ->method('listCertificates'); + ->expects($this->once()) + ->method('listCertificates') + ->willReturn([]); $this->assertEquals([ 'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt',