def get_public_key_from_certificate(certificate: Certificate) -> PublicKey: """Get public keys from certificate. :param certificate: certificate item :return: RSA public key """ public_key = certificate.public_key() assert isinstance(public_key, _PublicKeyTuple) return public_key
def get_public_key_from_certificate(certificate: Certificate) -> RSAPublicKey: """Get public keys from certificate. :param certificate: certificate item :return: RSA public key """ public_key = certificate.public_key() assert isinstance(public_key, RSAPublicKey), "Currently only RSA is supported" return public_key
def convert_certificate_into_bytes(certificate: Certificate, encoding: Encoding = Encoding.PEM) -> bytes: """Convert certificates into bytes. :param certificate: certificate item :param encoding: encoding type :return: certificate in bytes form """ assert isinstance(certificate, Certificate), "The input is not a Certificate" return certificate.public_bytes(encoding)