diff options
author | Julius Härtl <jus@bitgrid.net> | 2024-08-20 11:53:22 +0200 |
---|---|---|
committer | Julius Knorr <jus@bitgrid.net> | 2024-09-20 00:13:00 +0200 |
commit | 232c22fcd1652836c837aed04370ff0274d48678 (patch) | |
tree | 89e5f62d451f4d34d1887579e5322699aba6bfe3 /apps | |
parent | 2a59f4fc95305909b06f095fadb4770bfe8b3152 (diff) | |
download | nextcloud-server-232c22fcd1652836c837aed04370ff0274d48678.tar.gz nextcloud-server-232c22fcd1652836c837aed04370ff0274d48678.zip |
fix(federation): Do not overwrite certificate bundlefix/federation-certificate-store
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/External/Storage.php | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index bfaf9a99442..ba237f6c5ef 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -259,19 +259,12 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, $client = $this->httpClient->newClient(); try { - $result = $client->get($url, [ - 'timeout' => 10, - 'connect_timeout' => 10, - 'verify' => !$this->config->getSystemValueBool('sharing.federation.allowSelfSignedCertificates', false), - ])->getBody(); + $result = $client->get($url, $this->getDefaultRequestOptions())->getBody(); $data = json_decode($result); $returnValue = (is_object($data) && !empty($data->version)); - } catch (ConnectException $e) { - $returnValue = false; - } catch (ClientException $e) { - $returnValue = false; - } catch (RequestException $e) { + } catch (ConnectException|ClientException|RequestException $e) { $returnValue = false; + $this->logger->warning('Failed to test remote URL', ['exception' => $e]); } $cache->set($url, $returnValue, 60 * 60 * 24); @@ -319,12 +312,11 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, // TODO: DI $client = \OC::$server->getHTTPClientService()->newClient(); try { - $response = $client->post($url, [ + $response = $client->post($url, array_merge($this->getDefaultRequestOptions(), [ 'body' => ['password' => $password, 'depth' => $depth], - 'timeout' => 10, - 'connect_timeout' => 10, - ]); + ])); } catch (\GuzzleHttp\Exception\RequestException $e) { + $this->logger->warning('Failed to fetch share info', ['exception' => $e]); if ($e->getCode() === Http::STATUS_UNAUTHORIZED || $e->getCode() === Http::STATUS_FORBIDDEN) { throw new ForbiddenException(); } @@ -422,4 +414,15 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, public function free_space($path) { return parent::free_space(''); } + + private function getDefaultRequestOptions(): array { + $options = [ + 'timeout' => 10, + 'connect_timeout' => 10, + ]; + if ($this->config->getSystemValueBool('sharing.federation.allowSelfSignedCertificates')) { + $options['verify'] = false; + } + return $options; + } } |