diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-11-01 21:05:36 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-11-03 00:13:01 +0100 |
commit | 54b9f639a6cec14236f432c9907edb18d323d94d (patch) | |
tree | 712c0f6c7386edd726a464e3f38a99bfed95c278 /lib/private/Security | |
parent | dc479aae2d055dafddb250a382eb801a68d42afb (diff) | |
download | nextcloud-server-54b9f639a6cec14236f432c9907edb18d323d94d.tar.gz nextcloud-server-54b9f639a6cec14236f432c9907edb18d323d94d.zip |
Always return the default path if we can
Just check in the certifcate manager. So every part of the system that
request the certificatebundle gets the defaullt one (the 99% case) if we
can.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Security')
-rw-r--r-- | lib/private/Security/CertificateManager.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php index ed873527d3c..ef0c6563320 100644 --- a/lib/private/Security/CertificateManager.php +++ b/lib/private/Security/CertificateManager.php @@ -104,6 +104,29 @@ class CertificateManager implements ICertificateManager { return $result; } + private function hasCertificates(): bool { + if (!$this->config->getSystemValue('installed', false)) { + return false; + } + + $path = $this->getPathToCertificates() . 'uploads/'; + if (!$this->view->is_dir($path)) { + return false; + } + $result = []; + $handle = $this->view->opendir($path); + if (!is_resource($handle)) { + return false; + } + while (false !== ($file = readdir($handle))) { + if ($file !== '.' && $file !== '..') { + return true; + } + } + closedir($handle); + return false; + } + /** * create the certificate bundle of all trusted certificated */ @@ -213,9 +236,14 @@ class CertificateManager implements ICertificateManager { * @return string */ public function getAbsoluteBundlePath() { + if (!$this->hasCertificates()) { + return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; + } + if ($this->needsRebundling()) { $this->createCertificateBundle(); } + return $this->view->getLocalFile($this->getCertificateBundle()); } |