|
34 | 34 | from onelogin.saml2.constants import OneLogin_Saml2_Constants |
35 | 35 | from onelogin.saml2.errors import OneLogin_Saml2_Error |
36 | 36 |
|
| 37 | +if not globals().get('xmlsec_setup', False): |
| 38 | + xmlsec.initialize() |
| 39 | + globals()['xmlsec_setup'] = True |
| 40 | + |
37 | 41 |
|
38 | 42 | def print_xmlsec_errors(filename, line, func, error_object, error_subject, reason, msg): |
39 | 43 | """ |
@@ -626,7 +630,7 @@ def generate_name_id(value, sp_nq, sp_format, cert=None, debug=False, nq=None): |
626 | 630 | xml = name_id_container.toxml() |
627 | 631 | elem = fromstring(xml) |
628 | 632 |
|
629 | | - xmlsec.initialize() |
| 633 | + # xmlsec.initialize('openssl') # done when the module is loaded |
630 | 634 |
|
631 | 635 | if debug: |
632 | 636 | xmlsec.set_error_callback(print_xmlsec_errors) |
@@ -735,7 +739,7 @@ def decrypt_element(encrypted_data, key, debug=False): |
735 | 739 | elif isinstance(encrypted_data, basestring): |
736 | 740 | encrypted_data = fromstring(str(encrypted_data)) |
737 | 741 |
|
738 | | - xmlsec.initialize() |
| 742 | + # xmlsec.initialize() # Initialized at the start of the module |
739 | 743 |
|
740 | 744 | if debug: |
741 | 745 | xmlsec.set_error_callback(print_xmlsec_errors) |
@@ -810,7 +814,7 @@ def add_sign(xml, key, cert, debug=False, sign_algorithm=OneLogin_Saml2_Constant |
810 | 814 | else: |
811 | 815 | raise Exception('Error parsing xml string') |
812 | 816 |
|
813 | | - xmlsec.initialize() |
| 817 | + # xmlsec.initialize() # Initialized at the start of the module |
814 | 818 |
|
815 | 819 | if debug: |
816 | 820 | xmlsec.set_error_callback(print_xmlsec_errors) |
@@ -916,7 +920,7 @@ def validate_sign(xml, cert=None, fingerprint=None, fingerprintalg='sha1', valid |
916 | 920 | else: |
917 | 921 | raise Exception('Error parsing xml string') |
918 | 922 |
|
919 | | - xmlsec.initialize() |
| 923 | + # xmlsec.initialize() # Initialized at the start of the module |
920 | 924 |
|
921 | 925 | if debug: |
922 | 926 | xmlsec.set_error_callback(print_xmlsec_errors) |
@@ -981,7 +985,7 @@ def validate_metadata_sign(xml, cert=None, fingerprint=None, fingerprintalg='sha |
981 | 985 | else: |
982 | 986 | raise Exception('Error parsing xml string') |
983 | 987 |
|
984 | | - xmlsec.initialize() |
| 988 | + # xmlsec.initialize() # Initialized at the start of the module |
985 | 989 |
|
986 | 990 | if debug: |
987 | 991 | xmlsec.set_error_callback(print_xmlsec_errors) |
@@ -1034,7 +1038,7 @@ def validate_node_sign(signature_node, elem, cert=None, fingerprint=None, finger |
1034 | 1038 | :type: bool |
1035 | 1039 | """ |
1036 | 1040 | try: |
1037 | | - xmlsec.initialize() |
| 1041 | + # xmlsec.initialize() # Initialized at the start of the module |
1038 | 1042 |
|
1039 | 1043 | if debug: |
1040 | 1044 | xmlsec.set_error_callback(print_xmlsec_errors) |
@@ -1099,7 +1103,7 @@ def validate_binary_sign(signed_query, signature, cert=None, algorithm=OneLogin_ |
1099 | 1103 | :type: bool |
1100 | 1104 | """ |
1101 | 1105 | try: |
1102 | | - xmlsec.initialize() |
| 1106 | + # xmlsec.initialize() # Initialized at the start of the module |
1103 | 1107 |
|
1104 | 1108 | if debug: |
1105 | 1109 | xmlsec.set_error_callback(print_xmlsec_errors) |
|
0 commit comments