Revize 0fd6d825
Přidáno uživatelem Jan Pašek před asi 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 |
src/services/cryptography.py | ||
---|---|---|
355 | 355 |
""" |
356 | 356 |
return self.__run_for_output(["version"]).decode("utf-8") |
357 | 357 | |
358 |
def generate_crl(self, index_file_path: str) -> str: |
|
359 |
""" |
|
360 |
Generate a CertificateRevocationList for a specified |
|
361 |
certificate authority. |
|
362 | ||
363 |
:param index_file_path: path to a file that contains the openssl index with all revoked certificates |
|
364 |
:return: CRL encoded in PEM format string |
|
365 |
""" |
|
366 |
# TODO |
|
367 |
return "" |
|
358 | 368 | |
359 | 369 |
class CryptographyException(Exception): |
360 | 370 |
Také k dispozici: Unified diff
Re #8576 - CrlService implemented generate_crl_response(), prepared method generate_crl in CryptographyService