def encode_csr(self, req): enc = crypto.dump_certificate_request(crypto.FILETYPE_PEM, req) data = {'certificate_request': enc} return data