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
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2022-06-13 12:20:58 +0300
committerGitHub <noreply@github.com>2022-06-13 12:20:58 +0300
commitc46a8d8f86190a8ab25fc4bbe829b2015fea586a (patch)
treecab2830e543db6cdabad2409a470a0db39af2738 /lib/private
parentbe236efd2bc80dff914d76fd24777f4766fcb590 (diff)
parentd6097c9787d692c22e9b92263b1cbe51aa97518b (diff)
Merge pull request #31707 from nextcloud/backport/31605/stable22
[stable22] cache the path of the certificate bundle
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Security/CertificateManager.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php
index 6f3b01e23b9..df36efe1200 100644
--- a/lib/private/Security/CertificateManager.php
+++ b/lib/private/Security/CertificateManager.php
@@ -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
@@ -190,6 +193,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 +221,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 +247,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';
}