Skip to content

Commit 18b0d75

Browse files
committed
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 <[email protected]>
1 parent cbde1d1 commit 18b0d75

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

lib/private/Http/Client/Client.php

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

9999
private function getCertBundle(): string {
100-
if ($this->certificateManager->listCertificates() !== []) {
101-
return $this->certificateManager->getAbsoluteBundlePath();
102-
}
103-
104100
// If the instance is not yet setup we need to use the static path as
105101
// $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
106102
// a view
107-
if ($this->config->getSystemValue('installed', false)) {
108-
return $this->certificateManager->getAbsoluteBundlePath(null);
103+
if ($this->config->getSystemValue('installed', false) === false) {
104+
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
105+
}
106+
107+
if ($this->certificateManager->listCertificates() === []) {
108+
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
109109
}
110110

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

114114
/**

tests/lib/Http/Client/ClientTest.php

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

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

0 commit comments

Comments
 (0)