Revize 3243b35d
Přidáno uživatelem Michal Seják před téměř 4 roky(ů)
src/controllers/certificates_controller.py | ||
---|---|---|
15 | 15 |
from src.model.subject import Subject |
16 | 16 |
from src.services.certificate_service import CertificateService, RevocationReasonInvalidException, \ |
17 | 17 |
CertificateStatusInvalidException, CertificateNotFoundException, CertificateAlreadyRevokedException, \ |
18 |
CertificateCannotBeSetToValid, InvalidSubjectAttribute |
|
18 |
CertificateCannotBeSetToValid, InvalidSubjectAttribute, InvalidRootCA
|
|
19 | 19 |
# responsibility. |
20 | 20 |
from src.services.cryptography import CryptographyException |
21 | 21 |
from src.services.key_service import KeyService |
... | ... | |
455 | 455 |
Logger.error(f"Invalid request, wrong parameters 'id'[{id}].") |
456 | 456 |
return E_WRONG_PARAMETERS, C_BAD_REQUEST |
457 | 457 | |
458 |
cert = self.certificate_service.get_certificate(v) |
|
459 | ||
460 |
if cert is None: |
|
461 |
Logger.error(f"No such certificate found 'ID = {v}'.") |
|
462 |
return E_NO_CERTIFICATES_FOUND, C_NO_DATA |
|
463 | ||
464 |
trust_chain = self.certificate_service.get_chain_of_trust(cert.parent_id, exclude_root=False) |
|
465 |
if trust_chain is None or len(trust_chain) == 0: |
|
466 |
Logger.error(f"No such certificate found (empty list).") |
|
458 |
try: |
|
459 |
root = self.certificate_service.get_root(v) |
|
460 |
return {"success": True, "data": root.pem_data}, C_SUCCESS |
|
461 |
except CertificateNotFoundException: |
|
467 | 462 |
return E_NO_CERTIFICATES_FOUND, C_NO_DATA |
468 | ||
469 |
return {"success": True, "data": trust_chain[-1].pem_data}, C_SUCCESS
|
|
463 |
except InvalidRootCA: |
|
464 |
return E_CORRUPTED_DATABASE, C_INTERNAL_SERVER_ERROR
|
|
470 | 465 | |
471 | 466 |
def get_certificate_trust_chain_by_id(self, id): |
472 | 467 |
"""get certificate's trust chain by ID (including root certificate) |
Také k dispozici: Unified diff
Re #8589 - Updated CertificateController in order to use the new get_root function of CertService.