From ab301ad938ae2cb991a969b03c68c4628190bea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Ho=CC=88rberg?= Date: Mon, 5 May 2014 16:02:55 +0200 Subject: [PATCH] Fix for encrypted assertion. --- src/saml2/response.py | 2 +- src/saml2/sigver.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/saml2/response.py b/src/saml2/response.py index 7e0863180..1cbd236f8 100644 --- a/src/saml2/response.py +++ b/src/saml2/response.py @@ -809,7 +809,7 @@ def parse_assertion(self, key_file=""): if self.response.encrypted_assertion: logger.debug("***Encrypted assertion/-s***") - decr_text = self.sec.decrypt(self.xmlstr) + decr_text = self.sec.decrypt(self.xmlstr, key_file) resp = samlp.response_from_string(decr_text) res = self.decrypt_assertions(resp.encrypted_assertion, key_file) if self.response.assertion: diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py index 9db02bb44..6a5cdf686 100644 --- a/src/saml2/sigver.py +++ b/src/saml2/sigver.py @@ -1250,12 +1250,14 @@ def encrypt_assertion(self, statement, cert_file, cert_type="pem"): :return: """ - def decrypt(self, enctext): + def decrypt(self, enctext, key_file=None): """ Decrypting an encrypted text by the use of a private key. :param enctext: The encrypted text as a string :return: The decrypted text """ + if key_file is not None and len(key_file.strip()) > 0: + return self.crypto.decrypt(enctext, key_file) return self.crypto.decrypt(enctext, self.key_file) def verify_signature(self, signedtext, cert_file=None, cert_type="pem",