Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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)