99
1010from copy import deepcopy
1111
12-
1312try :
1413 import urllib .request as urllib2
1514except ImportError :
1615 import urllib2
1716
1817from onelogin .saml2 .constants import OneLogin_Saml2_Constants
1918from onelogin .saml2 .xml_utils import OneLogin_Saml2_XML
19+ from onelogin .saml2 .utils import OneLogin_Saml2_Utils
2020
2121
2222class OneLogin_Saml2_IdPMetadataParser (object ):
@@ -67,7 +67,9 @@ def parse_remote(url, **kwargs):
6767 def parse (
6868 idp_metadata ,
6969 required_sso_binding = OneLogin_Saml2_Constants .BINDING_HTTP_REDIRECT ,
70- required_slo_binding = OneLogin_Saml2_Constants .BINDING_HTTP_REDIRECT ):
70+ required_slo_binding = OneLogin_Saml2_Constants .BINDING_HTTP_REDIRECT ,
71+ index = 0
72+ ):
7173 """
7274 Parses the Identity Provider metadata and return a dict with extracted data.
7375
@@ -94,6 +96,9 @@ def parse(
9496 :type required_slo_binding: one of OneLogin_Saml2_Constants.BINDING_HTTP_REDIRECT
9597 or OneLogin_Saml2_Constants.BINDING_HTTP_POST
9698
99+ :param index: If the metadata contains more than 1 certificate, use index to get the right certificate.
100+ :type index: number
101+
97102 :returns: settings dict with extracted data
98103 :rtype: dict
99104 """
@@ -152,8 +157,7 @@ def parse(
152157 )
153158
154159 if len (cert_nodes ) > 0 :
155- # Remove leading and trailing and intermediate whitespace.
156- idp_x509_cert = '' .join (l for l in cert_nodes [0 ].text .split ())
160+ idp_x509_cert = OneLogin_Saml2_Utils .format_cert (cert_nodes [index ].text , False )
157161
158162 data ['idp' ] = {}
159163
0 commit comments