Skip to content

Commit d02d7ca

Browse files
salmart-devbackportbot[bot]
authored andcommitted
fix(files_sharing): respect config to skip certificate verification
This is important especially for local development, as certificate are self-signed. Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com> [skip ci]
1 parent 0e1824f commit d02d7ca

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

apps/files_sharing/lib/AppInfo/Application.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public function register(IRegistrationContext $context): void {
7272
function () use ($c) {
7373
return $c->get(Manager::class);
7474
},
75-
$c->get(ICloudIdManager::class)
75+
$c->get(ICloudIdManager::class),
76+
$c->get(IConfig::class),
7677
);
7778
});
7879

apps/files_sharing/tests/External/ManagerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ protected function setUp(): void {
9090
->disableOriginalConstructor()->getMock();
9191
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
9292
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
93+
$this->config = $this->createMock(IConfig::class);
9394
$this->groupManager = $this->createMock(IGroupManager::class);
9495
$this->userManager = $this->createMock(IUserManager::class);
9596
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);

lib/private/Files/Storage/DAV.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class DAV extends Common {
5050
protected $host;
5151
/** @var bool */
5252
protected $secure;
53+
protected bool $verify;
5354
/** @var string */
5455
protected $root;
5556
/** @var string */
@@ -104,12 +105,14 @@ public function __construct(array $parameters) {
104105
$this->authType = $parameters['authType'];
105106
}
106107
if (isset($parameters['secure'])) {
108+
$this->verify = $parameters['verify'] ?? true;
107109
if (is_string($parameters['secure'])) {
108110
$this->secure = ($parameters['secure'] === 'true');
109111
} else {
110112
$this->secure = (bool)$parameters['secure'];
111113
}
112114
} else {
115+
$this->verify = false;
113116
$this->secure = false;
114117
}
115118
if ($this->secure === true) {
@@ -153,6 +156,9 @@ protected function init(): void {
153156
$this->client->setThrowExceptions(true);
154157

155158
if ($this->secure === true) {
159+
if ($this->verify === false) {
160+
$this->client->addCurlSetting(CURLOPT_SSL_VERIFYPEER, false);
161+
}
156162
$certPath = $this->certManager->getAbsoluteBundlePath();
157163
if (file_exists($certPath)) {
158164
$this->certPath = $certPath;
@@ -331,7 +337,8 @@ public function fopen(string $path, string $mode) {
331337
'auth' => [$this->user, $this->password],
332338
'stream' => true,
333339
// set download timeout for users with slow connections or large files
334-
'timeout' => $this->timeout
340+
'timeout' => $this->timeout,
341+
'verify' => $this->verify,
335342
]);
336343
} catch (\GuzzleHttp\Exception\ClientException $e) {
337344
if ($e->getResponse() instanceof ResponseInterface
@@ -473,7 +480,8 @@ protected function uploadFile(string $path, string $target): void {
473480
'body' => $source,
474481
'auth' => [$this->user, $this->password],
475482
// set upload timeout for users with slow connections or large files
476-
'timeout' => $this->timeout
483+
'timeout' => $this->timeout,
484+
'verify' => $this->verify,
477485
]);
478486

479487
$this->removeCachedFile($target);

0 commit comments

Comments
 (0)