Revize ce8b9aaf
Přidáno uživatelem Stanislav Král před asi 4 roky(ů)
src/controllers/certificates_controller.py | ||
---|---|---|
345 | 345 |
CA: c_issuer.certificate_id |
346 | 346 |
} |
347 | 347 |
|
348 |
def get_public_key_of_a_certificate(self, id):
|
|
348 |
def get_private_key_of_a_certificate(self, id):
|
|
349 | 349 |
""" |
350 | 350 |
Get a private key used to sign a certificate in PEM format specified by certificate's ID |
351 | 351 |
|
352 |
:param id: ID of a certificate whose private key is to be queried |
|
353 |
:type id: dict | bytes |
|
354 |
|
|
355 |
:rtype: PemResponse |
|
356 |
""" |
|
357 |
|
|
358 |
# try to parse the supplied ID |
|
359 |
try: |
|
360 |
v = int(id) |
|
361 |
except ValueError: |
|
362 |
return E_WRONG_PARAMETERS, C_BAD_REQUEST |
|
363 |
|
|
364 |
# find a certificate with using the given ID |
|
365 |
cert = self.certificate_service.get_certificate(v) |
|
366 |
|
|
367 |
if cert is None: |
|
368 |
return E_NO_CERTIFICATES_FOUND, C_NOT_FOUND |
|
369 |
else: |
|
370 |
# certificate exists, fetch it's private key |
|
371 |
private_key = self.key_service.get_key(cert.private_key_id) |
|
372 |
if cert is None: |
|
373 |
return E_NO_CERT_PRIVATE_KEY_FOUND, C_INTERNAL_SERVER_ERROR |
|
374 |
else: |
|
375 |
return {"success": True, "data": private_key.private_key}, C_SUCCESS |
|
376 |
|
|
377 |
def get_public_key_of_a_certificate(self, id): |
|
378 |
""" |
|
379 |
Get a public key of a certificate in PEM format specified by certificate's ID |
|
380 |
|
|
352 | 381 |
:param id: ID of a certificate whose public key is to be queried |
353 | 382 |
:type id: dict | bytes |
354 | 383 |
|
Také k dispozici: Unified diff
Re #8573 - Implemented get_private_key_of_a_certificate method in CertController and added /api/certificates/<id>/private_key endpoint