Revize 11a90594
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
src/controllers/certificates_controller.py | ||
---|---|---|
276 | 276 |
cert = CERTIFICATE_SERVICE.get_certificate(v) |
277 | 277 |
|
278 | 278 |
if cert is None: |
279 |
return E_NO_CERTIFICATES_FOUND, C_NO_DATA
|
|
279 |
return E_NO_CERTIFICATES_FOUND, C_NO_DATA |
|
280 | 280 |
|
281 |
while cert.parent_id != cert.certificate_id: |
|
282 |
cert = CERTIFICATE_SERVICE.get_certificate(cert.parent_id) |
|
283 |
if cert is None: |
|
284 |
return E_CORRUPTED_DATABASE, C_INTERNAL_SERVER_ERROR |
|
281 |
trust_chain = CERTIFICATE_SERVICE.get_chain_of_trust(cert.parent_id, exclude_root=False) |
|
282 |
if trust_chain is None or len(trust_chain) is 0: |
|
283 |
return E_NO_CERTIFICATES_FOUND, C_NO_DATA |
|
285 | 284 |
|
286 |
return {"success": True, "data": cert.pem_data}, C_SUCCESS
|
|
285 |
return {"success": True, "data": trust_chain[-1].pem_data}, C_SUCCESS
|
|
287 | 286 |
|
288 | 287 |
@staticmethod |
289 | 288 |
def get_certificate_trust_chain_by_id(id): |
... | ... | |
308 | 307 |
if cert is None: |
309 | 308 |
return E_NO_CERTIFICATES_FOUND, C_NO_DATA |
310 | 309 |
|
311 |
ret = [] |
|
310 |
if cert.parent_id is None: |
|
311 |
return E_NO_CERTIFICATES_FOUND, C_NO_DATA |
|
312 | 312 |
|
313 |
while True: |
|
314 |
cert = CERTIFICATE_SERVICE.get_certificate(cert.parent_id) |
|
315 |
if cert is None: |
|
316 |
return E_CORRUPTED_DATABASE, C_INTERNAL_SERVER_ERROR |
|
317 |
elif cert.parent_id == cert.certificate_id: |
|
318 |
break |
|
319 |
ret.append(cert.pem_data) |
|
313 |
trust_chain = CERTIFICATE_SERVICE.get_chain_of_trust(cert.parent_id) |
|
314 |
|
|
315 |
ret = [] |
|
316 |
for intermediate in trust_chain: |
|
317 |
ret.append(intermediate.pem_data) |
|
320 | 318 |
|
321 | 319 |
return {"success": True, "data": "".join(ret)}, C_SUCCESS |
322 | 320 |
|
Také k dispozici: Unified diff
Re #8475 - Getting root and trust chain from controller uses correct service