From 7377015d4e94ef1e5f727df90a68309aa88b02ee Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 3 Jul 2020 14:20:55 +0200 Subject: [PATCH] Revert "[stable17] Do not read certificate bundle from data dir by default" --- 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 0753c932ac531..28694f3858502 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -76,18 +76,18 @@ private function buildRequestOptions(array $options): array { } 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) === false) { - return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; - } - - if ($this->certificateManager->listCertificates() === []) { - return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; + if ($this->config->getSystemValue('installed', false)) { + return $this->certificateManager->getAbsoluteBundlePath(null); } - 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 da96748f0673b..5c0693732bc20 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -262,8 +262,9 @@ public function testSetDefaultOptionsWithNotInstalled(): void { ->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',