Revize 0fd6d825
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
src/services/crl/crl_service.py | ||
---|---|---|
3 | 3 |
from injector import inject |
4 | 4 |
|
5 | 5 |
from src.dao.certificate_repository import CertificateRepository |
6 |
from src.exceptions.certificate_not_found_exception import CertificateNotFoundException |
|
6 | 7 |
from src.services.crl.ca_index_file_line_generator import create_index_file_revoked_line |
7 | 8 |
from src.services.cryptography import CryptographyService |
9 |
from src.utils.temporary_file import TemporaryFile |
|
8 | 10 |
|
9 | 11 |
|
10 | 12 |
class CrlService: |
... | ... | |
42 | 44 |
|
43 | 45 |
# join all lines with a new line |
44 | 46 |
return "\n".join(index_lines) |
47 |
|
|
48 |
def generate_crl_response(self, ca_id: int) -> str: |
|
49 |
""" |
|
50 |
Generate a CRL for the given certificate authority |
|
51 |
that contains all revoked certificates |
|
52 |
|
|
53 |
:param ca_id: ID of a CA whose CRL shall be generated |
|
54 |
:return: CRL in PEM format |
|
55 |
""" |
|
56 |
# check if the requested CA exists and if not throw an exception |
|
57 |
if self.certificate_repository.read(ca_id) is None: |
|
58 |
raise CertificateNotFoundException(ca_id) |
|
59 |
|
|
60 |
# Create an index file and call cryptography service to generate CRL |
|
61 |
with TemporaryFile("crl.index", self.create_revoked_index(ca_id)) as index_path: |
|
62 |
crl_content = self.cryptography_service.generate_crl(index_path) |
|
63 |
|
|
64 |
return crl_content |
Také k dispozici: Unified diff
Re #8576 - CrlService implemented generate_crl_response(), prepared method generate_crl in CryptographyService