Skip to content

Commit ebbdd2d

Browse files
MorrisJobkebackportbot[bot]
authored andcommitted
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 <hey@morrisjobke.de>
1 parent 33b06cf commit ebbdd2d

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

lib/private/Http/Client/Client.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,18 @@ private function buildRequestOptions(array $options): array {
9393
}
9494

9595
private function getCertBundle(): string {
96-
if ($this->certificateManager->listCertificates() !== []) {
97-
return $this->certificateManager->getAbsoluteBundlePath();
98-
}
99-
10096
// If the instance is not yet setup we need to use the static path as
10197
// $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
10298
// a view
103-
if ($this->config->getSystemValue('installed', false)) {
104-
return $this->certificateManager->getAbsoluteBundlePath(null);
99+
if ($this->config->getSystemValue('installed', false) === false) {
100+
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
101+
}
102+
103+
if ($this->certificateManager->listCertificates() === []) {
104+
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
105105
}
106106

107-
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
107+
return $this->certificateManager->getAbsoluteBundlePath();
108108
}
109109

110110
/**

tests/lib/Http/Client/ClientTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,8 @@ public function testSetDefaultOptionsWithNotInstalled(): void {
460460
->with('installed', false)
461461
->willReturn(false);
462462
$this->certificateManager
463-
->expects($this->once())
464-
->method('listCertificates')
465-
->willReturn([]);
463+
->expects($this->never())
464+
->method('listCertificates');
466465

467466
$this->assertEquals([
468467
'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt',

0 commit comments

Comments
 (0)