Projekt

Obecné

Profil

« Předchozí | Další » 

Revize d3bfacfc

Přidáno uživatelem Stanislav Král před asi 4 roky(ů)

Re #8573 - /api/certificates/{id}/public_key endpoint now does not extract public key from private key but does so directly from the certificate instead

Zobrazit rozdíly:

src/controllers/certificates_controller.py
396 396
        if cert is None:
397 397
            return E_NO_CERTIFICATES_FOUND, C_NOT_FOUND
398 398
        else:
399
            # certificate exists, fetch it's private key
400
            private_key = self.key_service.get_key(cert.private_key_id)
401
            if cert is None:
402
                return E_NO_CERT_PRIVATE_KEY_FOUND, C_INTERNAL_SERVER_ERROR
403
            else:
404
                # TODO public key can be extracted from a certificate
405
                # private key fetched, extract a public key from it
406
                public_key = self.key_service.get_public_key(private_key)
407
                return {"success": True, "data": public_key}, C_SUCCESS
399
            return {"success": True, "data": self.certificate_service.get_public_key_from_certificate(cert)}, C_SUCCESS
src/services/certificate_service.py
256 256
        """
257 257
        (subject, _, _) = self.cryptography_service.parse_cert_pem(certificate.pem_data)
258 258
        return subject
259

  
260
    def get_public_key_from_certificate(self, certificate: Certificate):
261
        """
262
        Extracts a public key from the given certificate
263
        :param certificate: an instance of the Certificate class containing the certificate from which a public key
264
        should be extracted.
265
        :return: a string containing the extracted public key in PEM format
266
        """
267
        return self.cryptography_service.extract_public_key_from_certificate(certificate.pem_data)

Také k dispozici: Unified diff