Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certificate manager fallback #42763

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

tcitworld
Copy link
Member

@tcitworld tcitworld commented Jan 14, 2024

Summary

CertificateManager doesn't seem to work propertly if the files_external app is disabled (the files get put in /tmp for no reason I know of), so let's store directly in /data/certificate_manager the bundled certificates. This always has to be done on local disk (even with primary ObjectStorage) as curl currently requires a path to the cert bundle.

Another way of doing it would be directly using a file given by the ITempManager, but it would need rebuilding the bundle and rewriting the file after each cron call. 😱

When we require PHP 8.1 we will be able to simply store the certificate bundle in database/memory/cache and pass it through the CURLOPT_SSLCERT_BLOB option.

TODO

  • adapt tests

Checklist

@tcitworld tcitworld added bug 2. developing Work in progress labels Jan 14, 2024
@tcitworld tcitworld added this to the Nextcloud 29 milestone Jan 14, 2024
@tcitworld tcitworld requested review from icewind1991, a team, ArtificialOwl and blizzz and removed request for a team January 14, 2024 19:12
@blizzz
Copy link
Member

blizzz commented Jan 15, 2024

Once upon a time, the whole logic was in files_external, iirc, as it started to with the support of custom CAs against file serves.

@blizzz
Copy link
Member

blizzz commented Jan 15, 2024

The path (and data) will be different when switching on or off files_external, right. That's a little unpredictable and confusing. When going to a different location, go fully there, and do a migration of the old data, if existing.

@tcitworld
Copy link
Member Author

I can do that, yeah.

I was wondering if there was a special reason of using files_external for that in the first place, but it doesn't seem to me 5d61b85

…rnal to data

CertificateManager doesn't work propertly if the files_external app is disabled, so let's store
directly in /data/certificate_manager the bundled certificates. This always has to be done on local
disk as curl currently requires a path to the cert bundle.

When we require PHP 8.1 we will be able to simply store the certificate
bundle in database/memory/cache and pass it through the CURLOPT_SSLCERT_BLOB option.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
@tcitworld tcitworld marked this pull request as ready for review February 1, 2024 17:43

public function __construct(
protected View $view,
protected IConfig $config,
protected LoggerInterface $logger,
protected ISecureRandom $random,
protected IAppManager $appManager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

Copy link
Member

@icewind1991 icewind1991 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current logic still goes through the NC fs instead of always storing the bundle on disk but your PR description implies this wouldn't be the case anymore

protected string $newRootPath;

public function __construct(protected View $view, protected IConfig $config) {
$this->newRootPath = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/data/certificate_manager';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double /data

}

protected function shouldRun(): bool {
return $this->view->file_exists($this->newRootPath . self::ROOT_CERTS_FILENAME);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like it's missing a negation

This was referenced Mar 12, 2024
This was referenced Mar 20, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
@botsarenthuman
Copy link

We are using S3 storage and see the SSL cert error due to not having files_external enabled, this PR is fantastic.

This was referenced Jul 30, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv modified the milestones: Nextcloud 30, Nextcloud 31 Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: NC28 CalDAV Exceptions when opening Calendar app
5 participants