Revize d53c2fdc
Přidáno uživatelem Michal Seják před více než 3 roky(ů)
src/controllers/certificates_controller.py | ||
---|---|---|
29 | 29 |
ID = "id" |
30 | 30 |
E_NO_ISSUER_FOUND = {"success": False, |
31 | 31 |
"data": "No certificate authority with such unique ID exists."} |
32 |
E_NO_CERTIFICATES_FOUND = {"success": False, "data": "No certificates found."}
|
|
32 |
E_NO_CERTIFICATES_FOUND = {"success": False, "data": "No such certificate found."}
|
|
33 | 33 |
E_NOT_JSON_FORMAT = {"success": False, "data": "The request must be JSON-formatted."} |
34 | 34 |
E_CORRUPTED_DATABASE = {"success": False, "data": "Internal server error (corrupted database)."} |
35 | 35 |
E_GENERAL_ERROR = {"success": False, "data": "Internal server error (unknown origin)."} |
... | ... | |
250 | 250 |
) |
251 | 251 |
return {"success": True, "data": ret} |
252 | 252 |
|
253 |
|
|
254 | 253 |
@staticmethod |
255 | 254 |
def get_certificate_root_by_id(id): # noqa: E501 |
256 | 255 |
"""get certificate's root of trust chain by ID |
... | ... | |
264 | 263 |
""" |
265 | 264 |
CertController.setup() # TODO remove after issue fixed |
266 | 265 |
|
267 |
if connexion.request.is_json: |
|
268 |
id = IdParameter.from_dict(connexion.request.get_json()) # noqa: E501 |
|
269 |
return 'do some magic!' |
|
266 |
try: |
|
267 |
v = int(id) |
|
268 |
except ValueError: |
|
269 |
return E_WRONG_PARAMETERS, 400 |
|
270 |
|
|
271 |
cert = CERTIFICATE_SERVICE.get_certificate(v) |
|
272 |
|
|
273 |
if cert is None: |
|
274 |
return E_NO_CERTIFICATES_FOUND, 205 # TODO related to 204 issue |
|
275 |
|
|
276 |
while cert.parent_id != cert.certificate_id: |
|
277 |
cert = CERTIFICATE_SERVICE.get_certificate(cert.parent_id) |
|
278 |
if cert is None: |
|
279 |
return E_CORRUPTED_DATABASE, 500 |
|
280 |
|
|
281 |
return {"success": True, "data": cert.pem_data} |
|
270 | 282 |
|
271 | 283 |
@staticmethod |
272 | 284 |
def get_certificate_trust_chain_by_id(id): # noqa: E501 |
Také k dispozici: Unified diff
Re #8476 - Implemented and tested `get_cert_root(id)`.