Skip to content

Commit c7ae041

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 e740627 commit c7ae041

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ protected function setUp(): void {
7272
->disableOriginalConstructor()->getMock();
7373
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
7474
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
75+
$this->config = $this->createMock(IConfig::class);
7576
$this->groupManager = $this->createMock(IGroupManager::class);
7677
$this->userManager = $this->createMock(IUserManager::class);
7778
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
@@ -95,7 +96,7 @@ protected function setUp(): void {
9596
$this->contactsManager,
9697
$this->createMock(IURLGenerator::class),
9798
$this->userManager,
98-
));
99+
), $this->config);
99100

100101
$group1 = $this->createMock(IGroup::class);
101102
$group1->expects($this->any())->method('getGID')->willReturn('group1');

lib/private/Files/Storage/DAV.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class DAV extends Common {
5252
protected $host;
5353
/** @var bool */
5454
protected $secure;
55+
protected bool $verify;
5556
/** @var string */
5657
protected $root;
5758
/** @var string */
@@ -106,12 +107,14 @@ public function __construct(array $parameters) {
106107
$this->authType = $parameters['authType'];
107108
}
108109
if (isset($parameters['secure'])) {
110+
$this->verify = $parameters['verify'] ?? true;
109111
if (is_string($parameters['secure'])) {
110112
$this->secure = ($parameters['secure'] === 'true');
111113
} else {
112114
$this->secure = (bool)$parameters['secure'];
113115
}
114116
} else {
117+
$this->verify = false;
115118
$this->secure = false;
116119
}
117120
if ($this->secure === true) {
@@ -155,6 +158,9 @@ protected function init(): void {
155158
$this->client->setThrowExceptions(true);
156159

157160
if ($this->secure === true) {
161+
if ($this->verify === false) {
162+
$this->client->addCurlSetting(CURLOPT_SSL_VERIFYPEER, false);
163+
}
158164
$certPath = $this->certManager->getAbsoluteBundlePath();
159165
if (file_exists($certPath)) {
160166
$this->certPath = $certPath;
@@ -361,7 +367,8 @@ public function fopen(string $path, string $mode) {
361367
'auth' => [$this->user, $this->password],
362368
'stream' => true,
363369
// set download timeout for users with slow connections or large files
364-
'timeout' => $this->timeout
370+
'timeout' => $this->timeout,
371+
'verify' => $this->verify,
365372
]);
366373
} catch (\GuzzleHttp\Exception\ClientException $e) {
367374
if ($e->getResponse() instanceof ResponseInterface
@@ -511,7 +518,8 @@ protected function uploadFile(string $path, string $target): void {
511518
'body' => $source,
512519
'auth' => [$this->user, $this->password],
513520
// set upload timeout for users with slow connections or large files
514-
'timeout' => $this->timeout
521+
'timeout' => $this->timeout,
522+
'verify' => $this->verify,
515523
]);
516524

517525
$this->removeCachedFile($target);

0 commit comments

Comments
 (0)