def dump_certificate(certificate, encoding='<STR_LIT>'):
if encoding not in set(['<STR_LIT>', '<STR_LIT>']):<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>repr(encoding)<EOL>))<EOL><DEDENT>is_oscrypto = isinstance(certificate, Certificate)<EOL>if not isinstance(certificate, x509.Certificate) and not is_oscrypto:<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(certificate)<EOL>))<EOL><DEDENT>if is_oscrypto:<EOL><INDENT>certificate = certificate.asn1<EOL><DEDENT>output = certificate.dump()<EOL>if encoding == '<STR_LIT>':<EOL><INDENT>output = pem.armor('<STR_LIT>', output)<EOL><DEDENT>return output<EOL>
Serializes a certificate object into a byte string

:param certificate:
    An oscrypto.asymmetric.Certificate or asn1crypto.x509.Certificate object

:param encoding:
    A unicode string of "pem" or "der"

:return:
    A byte string of the encoded certificate