@@ -944,21 +944,32 @@ def parse_assertion(self, keys=None):
944944 resp = self .response
945945 decr_text = str (self .response )
946946
947- while self .find_encrypt_data (resp ):
947+ decr_text_old = None
948+ while self .find_encrypt_data (resp ) and decr_text_old != decr_text :
949+ decr_text_old = decr_text
948950 try :
949951 decr_text = self .sec .decrypt_keys (decr_text , keys )
950952 except DecryptError as e :
951953 continue
952954 else :
953955 resp = samlp .response_from_string (decr_text )
956+ # check and prepare for comparison between str and unicode
957+ if type (decr_text_old ) != type (decr_text ):
958+ if isinstance (decr_text_old , six .binary_type ):
959+ decr_text_old = decr_text_old .decode ("utf-8" )
960+ else :
961+ decr_text_old = decr_text_old .encode ("utf-8" )
954962
955963 _enc_assertions = self .decrypt_assertions (
956964 resp .encrypted_assertion , decr_text
957965 )
966+
967+ decr_text_old = None
958968 while (
959969 self .find_encrypt_data (resp )
960970 or self .find_encrypt_data_assertion_list (_enc_assertions )
961- ):
971+ ) and decr_text_old != decr_text :
972+ decr_text_old = decr_text
962973 try :
963974 decr_text = self .sec .decrypt_keys (decr_text , keys )
964975 except DecryptError as e :
@@ -968,6 +979,12 @@ def parse_assertion(self, keys=None):
968979 _enc_assertions = self .decrypt_assertions (
969980 resp .encrypted_assertion , decr_text , verified = True
970981 )
982+ # check and prepare for comparison between str and unicode
983+ if type (decr_text_old ) != type (decr_text ):
984+ if isinstance (decr_text_old , six .binary_type ):
985+ decr_text_old = decr_text_old .decode ("utf-8" )
986+ else :
987+ decr_text_old = decr_text_old .encode ("utf-8" )
971988
972989 all_assertions = _enc_assertions
973990 if resp .assertion :
0 commit comments