mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
cache the path of the certificate bundle
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
bf48c0b1b4
commit
4f594dbf53
1 changed files with 15 additions and 7 deletions
|
|
@ -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';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue