code: def _validate_signature(minion_id, signature, impersonated_by_master):
      '''
      Validate that either minion with id minion_id, or the master, signed the
      request
      '''
      pki_dir = __opts__['pki_dir']
      if impersonated_by_master:
          public_key = '{0}/master.pub'.format(pki_dir)
      else:
          public_key = '{0}/minions/{1}'.format(pki_dir, minion_id)
  
      log.trace('Validating signature for %s', minion_id)
      signature = base64.b64decode(signature)
      if not salt.crypt.verify_signature(public_key, minion_id, signature):
          raise salt.exceptions.AuthenticationError(
              'Could not validate token request from {0}'.format(minion_id)
              )
      log.trace('Signature ok'f _validate_signature(minion_id, signature, impersonated_by_master):
      '''
      Validate that either minion with id minion_id, or the master, signed the
      request
      '''
      pki_dir = __opts__['pki_dir']
      if impersonated_by_master:
          public_key = '{0}/master.pub'.format(pki_dir)
      else:
          public_key = '{0}/minions/{1}'.format(pki_dir, minion_id)
  
      log.trace('Validating signature for %s', minion_id)
      signature = base64.b64decode(signature)
      if not salt.crypt.verify_signature(public_key, minion_id, signature):
          raise salt.exceptions.AuthenticationError(
              'Could not validate token request from {0}'.format(minion_id)
              )
      log.trace('Signature ok')
docs: Validate that either minion with id minion_id, or the master, signed the
      request