• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 21967842076

12 Feb 2026 11:09PM UTC coverage: 51.292%. First build
21967842076

Pull #6824

github

web-flow
Merge e1e14865d into 34f32c1fd
Pull Request #6824: fix: signature methods names

217 of 241 new or added lines in 21 files covered. (90.04%)

8989 of 17525 relevant lines covered (51.29%)

6.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lib/Service/Certificate/FileService.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Service\Certificate;
10

11
use OCA\Libresign\Enum\CertificateEngineType;
12
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
13
use Psr\Log\LoggerInterface;
14

15
class FileService {
16
        public function __construct(
17
                private CertificateEngineFactory $certificateEngineFactory,
18
                private LoggerInterface $logger,
19
        ) {
20
        }
57✔
21

22
        public function getRootCertificateByGeneration(string $instanceId, int $generation, CertificateEngineType $engineType): string {
23
                return $this->loadCertificateFileByGeneration($instanceId, $generation, $engineType, 'ca.pem');
7✔
24
        }
25

26
        public function getPrivateKeyByGeneration(string $instanceId, int $generation, CertificateEngineType $engineType): string {
27
                return $this->loadCertificateFileByGeneration($instanceId, $generation, $engineType, 'ca-key.pem');
2✔
28
        }
29

30
        private function loadCertificateFileByGeneration(string $instanceId, int $generation, CertificateEngineType $engineType, string $filename): string {
31
                try {
32
                        $engine = $this->certificateEngineFactory->getEngine($engineType->getEngineName());
9✔
33
                        if (!method_exists($engine, 'getConfigPathByParams')) {
7✔
NEW
34
                                return '';
×
35
                        }
36

37
                        $configPath = $engine->getConfigPathByParams($instanceId, $generation);
7✔
38
                        return $this->readCertificateFile($configPath . DIRECTORY_SEPARATOR . $filename);
7✔
39
                } catch (\Exception $e) {
2✔
40
                        $this->logger->debug('Failed to load certificate file', [
2✔
41
                                'instanceId' => $instanceId,
2✔
42
                                'generation' => $generation,
2✔
43
                                'engineType' => $engineType->value,
2✔
44
                                'filename' => $filename,
2✔
45
                                'error' => $e->getMessage(),
2✔
46
                        ]);
2✔
47
                        return '';
2✔
48
                }
49
        }
50

51
        private function readCertificateFile(string $filePath): string {
52
                if (!file_exists($filePath) || !is_readable($filePath)) {
7✔
53
                        return '';
7✔
54
                }
55

NEW
56
                $content = file_get_contents($filePath);
×
NEW
57
                return $content !== false ? $content : '';
×
58
        }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc