def sign_response(self, response): from saml2.sigver import sign_statement_using_xmlsec response = '%s' % response # Sign assertion in the response signed_response = sign_statement_using_xmlsec(response, "Response", xmlsec_binary, key_file=os.path.join(path, 'data', 'idp.key')) return signed_response