code: def validate_public_key(value):
      
      is_valid = False
      exc = None
  
      for load in (load_pem_public_key, load_ssh_public_key):
          if not is_valid:
              try:
                  load(value.encode('utf-8'), default_backend())
                  is_valid = True
              except Exception as e:
                  exc = e
  
      if not is_valid:
          raise ValidationError('Public key is invalid: %s' % exc)
docs: Check that the given value is a valid RSA Public key in either PEM or OpenSSH format. If it is invalid,
      raises ``django.core.exceptions.ValidationError``.