CheckUserCertificates.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de>
  5. * @copyright Copyright (c) 2022 Carl Schwan <carl@carlschwan.eu>
  6. *
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\Settings\SetupChecks;
  26. use OCP\IConfig;
  27. use OCP\IL10N;
  28. use OCP\SetupCheck\ISetupCheck;
  29. use OCP\SetupCheck\SetupResult;
  30. class CheckUserCertificates implements ISetupCheck {
  31. private string $configValue;
  32. public function __construct(
  33. private IL10N $l10n,
  34. IConfig $config,
  35. ) {
  36. $this->configValue = $config->getAppValue('files_external', 'user_certificate_scan', '');
  37. }
  38. public function getCategory(): string {
  39. return 'security';
  40. }
  41. public function getName(): string {
  42. return $this->l10n->t('Old administration imported certificates');
  43. }
  44. public function run(): SetupResult {
  45. // all fine if neither "not-run-yet" nor a result
  46. if ($this->configValue === '') {
  47. return SetupResult::success();
  48. }
  49. if ($this->configValue === 'not-run-yet') {
  50. return SetupResult::info($this->l10n->t('A background job is pending that checks for administration imported SSL certificates. Please check back later.'));
  51. }
  52. 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.'));
  53. }
  54. }