You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CheckUserCertificates.php 2.3KB

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