code: def parse_certificates(data, password):
      
  
      # PEM
      if is_pem(data):
          certs = []
          for cert in data.split(PEM_IDENTIFIER):
              try:
                  certs.append(
                      x509.load_pem_x509_certificate(
                          PEM_IDENTIFIER + cert, default_backend()))
              except Exception:
                  pass
          # Could be valid PEM but not certificates.
          if len(certs) > 0:
              return certs
  
      # PKCS12
      if is_pkcs12(data):
          try:
              p12 = crypto.load_pkcs12(data, password)
              data = crypto.dump_certificate(
                  crypto.FILETYPE_PEM, p12.get_certificate())
              return [x509.load_pem_x509_certificate(data, default_backend())]
          except crypto.Error as e:
              raise ValueError(e)
  
      # DER
      try:
          return [x509.load_der_x509_certificate(data, default_backend())]
      except Exception:
          pass
  
      raise ValueError('Could not parse certificate.')
docs: Identifies, decrypts and returns list of cryptography x509 certificates.