summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2023-05-04 21:53:49 +0200
committerGitHub <noreply@github.com>2023-05-04 21:53:49 +0200
commit46459ae93fd2fe76a684569d802e7c8972098005 (patch)
tree3478445556a39528d4c2e7d4503ac7cf6513e268
parentf4e5d3d4e7082e9a7d4890cdf6ced611fbd0d7f0 (diff)
parent647c65a640f3e4c4b27e96f63684be2a2f55674f (diff)
downloadnextcloud-server-46459ae93fd2fe76a684569d802e7c8972098005.tar.gz
nextcloud-server-46459ae93fd2fe76a684569d802e7c8972098005.zip
Merge pull request #35092 from Messj1/bugfix/type-error-cert-manager-cache-path
-rw-r--r--lib/private/Security/CertificateManager.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php
index ee68f602bd1..b9fbdcc9f02 100644
--- a/lib/private/Security/CertificateManager.php
+++ b/lib/private/Security/CertificateManager.php
@@ -138,6 +138,10 @@ class CertificateManager implements ICertificateManager {
$tmpPath = $certPath . '.tmp' . $this->random->generate(10, ISecureRandom::CHAR_DIGITS);
$fhCerts = $this->view->fopen($tmpPath, 'w');
+ if (!is_resource($fhCerts)) {
+ throw new \RuntimeException('Unable to open file handler to create certificate bundle "' . $tmpPath . '".');
+ }
+
// Write user certificates
foreach ($certs as $cert) {
$file = $path . '/uploads/' . $cert->getName();
@@ -228,7 +232,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 +241,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';
}
}