From ebbdd2de33771751b4d0ff16743763e4804f5a03 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 25 May 2020 15:03:52 +0200 Subject: [PATCH] Do not read certificate bundle from data dir by default 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 --- lib/private/Http/Client/Client.php | 14 +++++++------- tests/lib/Http/Client/ClientTest.php | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index d19f1124a2..c0b05c48b9 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -93,18 +93,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'; } - return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; + if ($this->certificateManager->listCertificates() === []) { + return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; + } + + return $this->certificateManager->getAbsoluteBundlePath(); } /** diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index b136a0ca30..bd9cab023f 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -460,9 +460,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',