Skip to content

Commit

Permalink
Do not read certificate bundle from data dir by default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
MorrisJobke authored and backportbot[bot] committed May 25, 2020
1 parent b23db65 commit 4257de3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 7 additions & 7 deletions lib/private/Http/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
return $this->certificateManager->getAbsoluteBundlePath(null);
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';
}

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

/**
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/Http/Client/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,8 @@ public function testSetDefaultOptionsWithNotInstalled(): void {
->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',
Expand Down

0 comments on commit 4257de3

Please sign in to comment.