code: def pem_as_string(cert):
      
      if hasattr(cert, 'read'): # File object - return as is
          return cert
      cert = cert.encode('utf-8') if isinstance(cert, unicode) else cert
      if re.match(_PEM_RE, cert):
          return True
      return False
docs: Only return False if the certificate is a file path. Otherwise it
      is a file object or raw string and will need to be fed to the
      file open context.