Merge pull request #59051 from nextcloud/backport/58724/stable32
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Integration sqlite / changes (push) Waiting to run
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, --tags ~@large files_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, capabilities_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, collaboration_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, comments_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, dav_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, federation_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, file_conversions) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, files_reminders) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, filesdrop_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, ldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, openldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, openldap_numerical_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, remoteapi_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, routing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, setup_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, sharees_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, sharing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, theming_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, videoverification_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite-summary (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis (push) Waiting to run
Psalm static code analysis / static-code-analysis-security (push) Waiting to run
Psalm static code analysis / static-code-analysis-ocp (push) Waiting to run
Psalm static code analysis / static-code-analysis-ncu (push) Waiting to run

[stable32] fix(files_sharing): respect config to skip certificate verification
This commit is contained in:
Andy Scherzinger 2026-03-19 17:53:45 +01:00 committed by GitHub
commit 9a7037f446
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 5 deletions

View file

@ -49,6 +49,7 @@ use OCP\Files\Events\Node\BeforeNodeReadEvent;
use OCP\Group\Events\GroupChangedEvent;
use OCP\Group\Events\GroupDeletedEvent;
use OCP\Group\Events\UserAddedEvent;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\Share\Events\ShareCreatedEvent;
@ -72,7 +73,8 @@ class Application extends App implements IBootstrap {
function () use ($c) {
return $c->get(Manager::class);
},
$c->get(ICloudIdManager::class)
$c->get(ICloudIdManager::class),
$c->get(IConfig::class),
);
});

View file

@ -22,6 +22,7 @@ use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUserManager;
@ -55,6 +56,7 @@ class Manager {
IUserSession $userSession,
private IEventDispatcher $eventDispatcher,
private LoggerInterface $logger,
private IConfig $config,
) {
$user = $userSession->getUser();
$this->uid = $user ? $user->getUID() : null;
@ -124,7 +126,8 @@ class Manager {
'token' => $token,
'password' => $password,
'mountpoint' => $mountPoint,
'owner' => $owner
'owner' => $owner,
'verify' => !$this->config->getSystemValueBool('sharing.federation.allowSelfSignedCertificates'),
];
return $this->mountShare($options, $user);
}

View file

@ -12,6 +12,7 @@ use OCP\Federation\ICloudIdManager;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\Server;
@ -33,6 +34,7 @@ class MountProvider implements IMountProvider {
private IDBConnection $connection,
callable $managerProvider,
private ICloudIdManager $cloudIdManager,
private IConfig $config,
) {
$this->managerProvider = $managerProvider;
}
@ -46,6 +48,7 @@ class MountProvider implements IMountProvider {
$data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']);
$data['certificateManager'] = \OC::$server->getCertificateManager();
$data['HttpClientService'] = Server::get(IClientService::class);
$data['verify'] = !$this->config->getSystemValueBool('sharing.federation.allowSelfSignedCertificates');
return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
}

View file

@ -24,6 +24,7 @@ use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IGroupManager;
@ -61,6 +62,7 @@ class ManagerTest extends TestCase {
protected ICloudFederationFactory&MockObject $cloudFederationFactory;
protected IGroupManager&MockObject $groupManager;
protected IUserManager&MockObject $userManager;
private IConfig $config;
protected function setUp(): void {
parent::setUp();
@ -72,6 +74,7 @@ class ManagerTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
$this->config = $this->createMock(IConfig::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
@ -95,7 +98,7 @@ class ManagerTest extends TestCase {
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->userManager,
));
), $this->config);
$group1 = $this->createMock(IGroup::class);
$group1->expects($this->any())->method('getGID')->willReturn('group1');
@ -147,6 +150,7 @@ class ManagerTest extends TestCase {
$userSession,
$this->eventDispatcher,
$this->logger,
$this->config,
]
)->onlyMethods(['tryOCMEndPoint'])->getMock();
}

View file

@ -52,6 +52,7 @@ class DAV extends Common {
protected $host;
/** @var bool */
protected $secure;
protected bool $verify;
/** @var string */
protected $root;
/** @var string */
@ -106,12 +107,14 @@ class DAV extends Common {
$this->authType = $parameters['authType'];
}
if (isset($parameters['secure'])) {
$this->verify = $parameters['verify'] ?? true;
if (is_string($parameters['secure'])) {
$this->secure = ($parameters['secure'] === 'true');
} else {
$this->secure = (bool)$parameters['secure'];
}
} else {
$this->verify = false;
$this->secure = false;
}
if ($this->secure === true) {
@ -155,6 +158,9 @@ class DAV extends Common {
$this->client->setThrowExceptions(true);
if ($this->secure === true) {
if ($this->verify === false) {
$this->client->addCurlSetting(CURLOPT_SSL_VERIFYPEER, false);
}
$certPath = $this->certManager->getAbsoluteBundlePath();
if (file_exists($certPath)) {
$this->certPath = $certPath;
@ -361,7 +367,8 @@ class DAV extends Common {
'auth' => [$this->user, $this->password],
'stream' => true,
// set download timeout for users with slow connections or large files
'timeout' => $this->timeout
'timeout' => $this->timeout,
'verify' => $this->verify,
]);
} catch (\GuzzleHttp\Exception\ClientException $e) {
if ($e->getResponse() instanceof ResponseInterface
@ -511,7 +518,8 @@ class DAV extends Common {
'body' => $source,
'auth' => [$this->user, $this->password],
// set upload timeout for users with slow connections or large files
'timeout' => $this->timeout
'timeout' => $this->timeout,
'verify' => $this->verify,
]);
$this->removeCachedFile($target);