Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions lib/private/Security/CertificateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class CertificateManager implements ICertificateManager {
/** @var ISecureRandom */
protected $random;

/** @var string $bundlePath */
private $bundlePath = null;

/**
* @param \OC\Files\View $view relative to data/
* @param IConfig $config
Expand Down Expand Up @@ -190,6 +193,7 @@ public function addCertificate(string $certificate, string $name): ICertificate
if (!Filesystem::isValidPath($name) or Filesystem::isFileBlacklisted($name)) {
throw new \Exception('Filename is not valid');
}
$this->bundlePath = null;

$dir = $this->getPathToCertificates() . 'uploads/';
if (!$this->view->file_exists($dir)) {
Expand Down Expand Up @@ -217,6 +221,8 @@ public function removeCertificate(string $name): bool {
if (!Filesystem::isValidPath($name)) {
return false;
}
$this->bundlePath = null;

$path = $this->getPathToCertificates() . 'uploads/';
if ($this->view->file_exists($path . $name)) {
$this->view->unlink($path . $name);
Expand All @@ -241,15 +247,18 @@ public function getCertificateBundle(): string {
*/
public function getAbsoluteBundlePath(): string {
try {
if (!$this->hasCertificates()) {
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
}
if (!$this->bundlePath) {
if (!$this->hasCertificates()) {
$this->bundlePath = \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
}

if ($this->needsRebundling()) {
$this->createCertificateBundle();
}
if ($this->needsRebundling()) {
$this->createCertificateBundle();
}

return $this->view->getLocalFile($this->getCertificateBundle());
$this->bundlePath = $this->view->getLocalFile($this->getCertificateBundle());
}
return $this->bundlePath;
} catch (\Exception $e) {
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
}
Expand Down