ExportCertificates.php 905 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-only
  5. */
  6. declare(strict_types=1);
  7. namespace OC\Core\Command\Security;
  8. use OC\Core\Command\Base;
  9. use OCP\ICertificateManager;
  10. use Symfony\Component\Console\Input\InputInterface;
  11. use Symfony\Component\Console\Output\OutputInterface;
  12. class ExportCertificates extends Base {
  13. public function __construct(
  14. protected ICertificateManager $certificateManager,
  15. ) {
  16. parent::__construct();
  17. }
  18. protected function configure(): void {
  19. $this
  20. ->setName('security:certificates:export')
  21. ->setDescription('export the certificate bundle');
  22. }
  23. protected function execute(InputInterface $input, OutputInterface $output): int {
  24. $bundlePath = $this->certificateManager->getAbsoluteBundlePath();
  25. $bundle = file_get_contents($bundlePath);
  26. $output->writeln($bundle);
  27. return 0;
  28. }
  29. }