123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- # SPDX-FileCopyrightText: 2023 Helmut Pozimski <helmut@pozimski.eu>
- #
- # SPDX-License-Identifier: GPL-2.0-only
- import ntpath
- import os
- from abc import ABC, abstractmethod
- # -*- coding: utf8 -*-
- class CertPathProvider(ABC):
- @abstractmethod
- def provide_fullchain_path(self, fqdn: str) -> ntpath:
- pass
- @abstractmethod
- def provide_key_path(self, fqdn: str) -> ntpath:
- pass
- class AcmeToolCertPathProvider(CertPathProvider):
- def __init__(self, acme_dir: str):
- self._acme_dir = acme_dir
- def provide_key_path(self, fqdn: str) -> ntpath:
- return self._join_paths(fqdn, "privkey")
- def _join_paths(self, fqdn: str, file_name: str) -> ntpath:
- return os.path.join(self._acme_dir, "live", fqdn, file_name)
- def provide_fullchain_path(self, fqdn: str) -> ntpath:
- return self._join_paths(fqdn, "fullchain")
- class GetSslCertPathProvider(CertPathProvider):
- def __init__(self, acme_dir: str):
- self._acme_dir = acme_dir
- def _join_paths(self, fqdn: str, file_name: str) -> ntpath:
- return os.path.join(self._acme_dir, fqdn, file_name)
- def provide_fullchain_path(self, fqdn: str) -> ntpath:
- return self._join_paths(fqdn, "fullchain.crt")
- def provide_key_path(self, fqdn: str) -> ntpath:
- return self._join_paths(fqdn, fqdn + ".key")
|