1
0

CheckUserCertificates.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\SetupChecks;
  8. use OCP\IConfig;
  9. use OCP\IL10N;
  10. use OCP\SetupCheck\ISetupCheck;
  11. use OCP\SetupCheck\SetupResult;
  12. class CheckUserCertificates implements ISetupCheck {
  13. private string $configValue;
  14. public function __construct(
  15. private IL10N $l10n,
  16. IConfig $config,
  17. ) {
  18. $this->configValue = $config->getAppValue('files_external', 'user_certificate_scan', '');
  19. }
  20. public function getCategory(): string {
  21. return 'security';
  22. }
  23. public function getName(): string {
  24. return $this->l10n->t('Old administration imported certificates');
  25. }
  26. public function run(): SetupResult {
  27. // all fine if neither "not-run-yet" nor a result
  28. if ($this->configValue === '') {
  29. return SetupResult::success();
  30. }
  31. if ($this->configValue === 'not-run-yet') {
  32. return SetupResult::info($this->l10n->t('A background job is pending that checks for administration imported SSL certificates. Please check back later.'));
  33. }
  34. return SetupResult::error($this->l10n->t('There are some administration imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.'));
  35. }
  36. }