code: def chainCerts(data):
      
      matches = re.findall(
          r'(-----BEGIN CERTIFICATE-----\n.+?\n-----END CERTIFICATE-----)',
          data,
          flags=re.DOTALL)
      chainCertificates = [
          Certificate.loadPEM(chainCertPEM).original
          for chainCertPEM in matches]
      return chainCertificates[1:]
docs: Matches and returns any certificates found except the first match.
  
      Regex code copied from L{twisted.internet.endpoints._parseSSL}.
      Related ticket: https://twistedmatrix.com/trac/ticket/7732
  
      @type path: L{bytes}
      @param data: PEM-encoded data containing the certificates.
  
      @rtype: L{list} containing L{Certificate}s.