code: def get_metadata(url, validate_cert=True):
          
          valid = False
          if validate_cert:
              response = urllib2.urlopen(url)
          else:
              ctx = ssl.create_default_context()
              ctx.check_hostname = False
              ctx.verify_mode = ssl.CERT_NONE
              response = urllib2.urlopen(url, context=ctx)
          xml = response.read()
  
          if xml:
              try:
                  dom = fromstring(xml, forbid_dtd=True)
                  idp_descriptor_nodes = OneLogin_Saml2_Utils.query(dom, '//md:IDPSSODescriptor')
                  if idp_descriptor_nodes:
                      valid = True
              except Exception:
                  pass
  
          if not valid:
              raise Exception('Not valid IdP XML found from URL: %s' % (url))
  
          return xml
docs: Gets the metadata XML from the provided URL
  
          :param url: Url where the XML of the Identity Provider Metadata is published.
          :type url: string
  
          :param validate_cert: If the url uses https schema, that flag enables or not the verification of the associated certificate.
          :type validate_cert: bool
  
          :returns: metadata XML
          :rtype: string