#NEWLINE# def load_certificate_request( type , buffer ) : #NEWLINE# #INDENT# '\n    Load a certificate request from a buffer\n\n    :param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1)\n    :param buffer: The buffer the certificate request is stored in\n    :return: The X509Req object\n    ' #NEWLINE# if isinstance ( x509req , _text_type ) : #NEWLINE# #INDENT# buffer = buffer . encode ( 'ascii' ) #NEWLINE# #UNINDENT# bio = _new_mem_buf ( buffer ) #NEWLINE# if ( type == FILETYPE_PEM ) : #NEWLINE# #INDENT# req = _lib . PEM_read_bio_X509_REQ ( bio , _ffi . NULL , _ffi . NULL , _ffi . NULL ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == FILETYPE_ASN1 ) : #NEWLINE# #INDENT# req = _lib . d2i_X509_REQ_bio ( bio , _ffi . NULL ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'type argument must be FILETYPE_PEM or FILETYPE_ASN1' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( req == _ffi . NULL ) : #NEWLINE# #INDENT# _raise_current_error ( ) #NEWLINE# #UNINDENT# x509req = X509Req . __new__ ( X509Req ) #NEWLINE# x509req . _req = _ffi . gc ( req , _lib . X509_REQ_free ) #NEWLINE# return x509req