Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-03-22 12:46:35 +0300
committerGitHub <noreply@github.com>2022-03-22 12:46:35 +0300
commit5e1a397fbde741f9af532118315c13d93a544a6d (patch)
tree8cfb9fba9eb26deb13242161b75478a38ddf9ce7 /lib
parent6fa51be0deaebde10c5382739c1413cec183860a (diff)
parent4f594dbf5395c2ad8b9dffe772870e66cbab55eb (diff)
Merge pull request #31605 from nextcloud/cert-manager-cache-path
cache the path of the certificate bundle
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Security/CertificateManager.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php
index 6f3b01e23b9..74ea59c3792 100644
--- a/lib/private/Security/CertificateManager.php
+++ b/lib/private/Security/CertificateManager.php
@@ -61,6 +61,8 @@ class CertificateManager implements ICertificateManager {
/** @var ISecureRandom */
protected $random;
+ private ?string $bundlePath = null;
+
/**
* @param \OC\Files\View $view relative to data/
* @param IConfig $config
@@ -190,6 +192,7 @@ class CertificateManager implements ICertificateManager {
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)) {
@@ -217,6 +220,8 @@ class CertificateManager implements ICertificateManager {
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);
@@ -241,15 +246,18 @@ class CertificateManager implements ICertificateManager {
*/
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';
}