aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Security
diff options
context:
space:
mode:
authorJan Messer <jan@mtec-studios.ch>2022-11-11 02:52:32 +0100
committerJan Messer <jan@mtec-studios.ch>2023-04-06 23:03:33 +0200
commit7a443863fe8fba0f33d1eee86d85dd3d5bea2fb6 (patch)
tree8f2e15187af50a439a041f1d310fba8917bf4533 /lib/private/Security
parent012624743917cf9388f2abd33760a50d83d497e9 (diff)
downloadnextcloud-server-7a443863fe8fba0f33d1eee86d85dd3d5bea2fb6.tar.gz
nextcloud-server-7a443863fe8fba0f33d1eee86d85dd3d5bea2fb6.zip
[BUGFIX] check return value and improve error handling
With S3 primary storage there was a problem with getting the CA bundle from the storage without having the CA bundle for the connection which causes that the CertificateManager was throwing an Error. This commit improves the handling in CertificateManager and log unexpected behaviors. Signed-off-by: Jan Messer <jan@mtec-studios.ch>
Diffstat (limited to 'lib/private/Security')
-rw-r--r--lib/private/Security/CertificateManager.php13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php
index be884654bd0..bcc992caa5d 100644
--- a/lib/private/Security/CertificateManager.php
+++ b/lib/private/Security/CertificateManager.php
@@ -228,7 +228,7 @@ class CertificateManager implements ICertificateManager {
*/
public function getAbsoluteBundlePath(): string {
try {
- if (!$this->bundlePath) {
+ if ($this->bundlePath === null) {
if (!$this->hasCertificates()) {
$this->bundlePath = \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
}
@@ -237,13 +237,16 @@ class CertificateManager implements ICertificateManager {
$this->createCertificateBundle();
}
- $this->bundlePath = $this->view->getLocalFile($this->getCertificateBundle()) ?: null;
- }
- if ($this->bundlePath === null) {
- throw new \Exception('Failed to get absolute bundle path');
+ $certificateBundle = $this->getCertificateBundle();
+ $this->bundlePath = $this->view->getLocalFile($certificateBundle) ?: null;
+
+ if ($this->bundlePath === null) {
+ throw new \RuntimeException('Unable to get certificate bundle "' . $certificateBundle . '".');
+ }
}
return $this->bundlePath;
} catch (\Exception $e) {
+ $this->logger->error('Failed to get absolute bundle path. Fallback to default ca-bundle.crt', ['exception' => $e]);
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
}
}