Skip to content

Commit f026024

Browse files
Merge pull request #45879 from nextcloud/export-certificate-bundle
feat: add command to export certificate bundle
2 parents 203581e + 9a06931 commit f026024

File tree

4 files changed

+38
-0
lines changed

4 files changed

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

core/register_command.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
$application->add(Server::get(Command\SystemTag\Edit::class));
137137

138138
$application->add(Server::get(Command\Security\ListCertificates::class));
139+
$application->add(Server::get(Command\Security\ExportCertificates::class));
139140
$application->add(Server::get(Command\Security\ImportCertificate::class));
140141
$application->add(Server::get(Command\Security\RemoveCertificate::class));
141142
$application->add(Server::get(Command\Security\BruteforceAttempts::class));

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@
12051205
'OC\\Core\\Command\\Preview\\ResetRenderedTexts' => $baseDir . '/core/Command/Preview/ResetRenderedTexts.php',
12061206
'OC\\Core\\Command\\Security\\BruteforceAttempts' => $baseDir . '/core/Command/Security/BruteforceAttempts.php',
12071207
'OC\\Core\\Command\\Security\\BruteforceResetAttempts' => $baseDir . '/core/Command/Security/BruteforceResetAttempts.php',
1208+
'OC\\Core\\Command\\Security\\ExportCertificates' => $baseDir . '/core/Command/Security/ExportCertificates.php',
12081209
'OC\\Core\\Command\\Security\\ImportCertificate' => $baseDir . '/core/Command/Security/ImportCertificate.php',
12091210
'OC\\Core\\Command\\Security\\ListCertificates' => $baseDir . '/core/Command/Security/ListCertificates.php',
12101211
'OC\\Core\\Command\\Security\\RemoveCertificate' => $baseDir . '/core/Command/Security/RemoveCertificate.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
12381238
'OC\\Core\\Command\\Preview\\ResetRenderedTexts' => __DIR__ . '/../../..' . '/core/Command/Preview/ResetRenderedTexts.php',
12391239
'OC\\Core\\Command\\Security\\BruteforceAttempts' => __DIR__ . '/../../..' . '/core/Command/Security/BruteforceAttempts.php',
12401240
'OC\\Core\\Command\\Security\\BruteforceResetAttempts' => __DIR__ . '/../../..' . '/core/Command/Security/BruteforceResetAttempts.php',
1241+
'OC\\Core\\Command\\Security\\ExportCertificates' => __DIR__ . '/../../..' . '/core/Command/Security/ExportCertificates.php',
12411242
'OC\\Core\\Command\\Security\\ImportCertificate' => __DIR__ . '/../../..' . '/core/Command/Security/ImportCertificate.php',
12421243
'OC\\Core\\Command\\Security\\ListCertificates' => __DIR__ . '/../../..' . '/core/Command/Security/ListCertificates.php',
12431244
'OC\\Core\\Command\\Security\\RemoveCertificate' => __DIR__ . '/../../..' . '/core/Command/Security/RemoveCertificate.php',

0 commit comments

Comments
 (0)