@@ -944,21 +944,32 @@ def parse_assertion(self, keys=None):
944
944
resp = self .response
945
945
decr_text = str (self .response )
946
946
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
948
950
try :
949
951
decr_text = self .sec .decrypt_keys (decr_text , keys )
950
952
except DecryptError as e :
951
953
continue
952
954
else :
953
955
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" )
954
962
955
963
_enc_assertions = self .decrypt_assertions (
956
964
resp .encrypted_assertion , decr_text
957
965
)
966
+
967
+ decr_text_old = None
958
968
while (
959
969
self .find_encrypt_data (resp )
960
970
or self .find_encrypt_data_assertion_list (_enc_assertions )
961
- ):
971
+ ) and decr_text_old != decr_text :
972
+ decr_text_old = decr_text
962
973
try :
963
974
decr_text = self .sec .decrypt_keys (decr_text , keys )
964
975
except DecryptError as e :
@@ -968,6 +979,12 @@ def parse_assertion(self, keys=None):
968
979
_enc_assertions = self .decrypt_assertions (
969
980
resp .encrypted_assertion , decr_text , verified = True
970
981
)
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" )
971
988
972
989
all_assertions = _enc_assertions
973
990
if resp .assertion :
0 commit comments