def load_certificate(type, buffer):
if isinstance(buffer, _text_type):<EOL><INDENT>buffer = buffer.encode("<STR_LIT:ascii>")<EOL><DEDENT>bio = _new_mem_buf(buffer)<EOL>if type == FILETYPE_PEM:<EOL><INDENT>x509 = _lib.PEM_read_bio_X509(bio, _ffi.NULL, _ffi.NULL, _ffi.NULL)<EOL><DEDENT>elif type == FILETYPE_ASN1:<EOL><INDENT>x509 = _lib.d2i_X509_bio(bio, _ffi.NULL)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT>if x509 == _ffi.NULL:<EOL><INDENT>_raise_current_error()<EOL><DEDENT>return X509._from_raw_x509_ptr(x509)<EOL>
Load a certificate (X509) from the string *buffer* encoded with the
type *type*.

:param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1)

:param bytes buffer: The buffer the certificate is stored in

:return: The X509 object