Skip to content

Commit

Permalink
feat: add command to export certificate bundle
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jun 14, 2024
1 parent 3a60e40 commit 601437f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions core/Command/Security/ExportCertificates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
declare(strict_types=1);

namespace OC\Core\Command\Security;

use OC\Core\Command\Base;
use OCP\ICertificateManager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ExportCertificates extends Base {
public function __construct(
protected ICertificateManager $certificateManager,
) {
parent::__construct();
}

protected function configure() {

Check notice

Code scanning / Psalm

MissingReturnType Note

Method OC\Core\Command\Security\ExportCertificates::configure does not have a return type, expecting void
$this
->setName('security:certificates:export')
->setDescription('export the certificate bundle');
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$bundlePath = $this->certificateManager->getAbsoluteBundlePath();
$bundle = file_get_contents($bundlePath);
$output->writeln($bundle);
return 0;
}
}
1 change: 1 addition & 0 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
$application->add(Server::get(Command\SystemTag\Edit::class));

$application->add(Server::get(Command\Security\ListCertificates::class));
$application->add(Server::get(Command\Security\ExportCertificates::class));
$application->add(Server::get(Command\Security\ImportCertificate::class));
$application->add(Server::get(Command\Security\RemoveCertificate::class));
$application->add(Server::get(Command\Security\BruteforceAttempts::class));
Expand Down

0 comments on commit 601437f

Please sign in to comment.