code: def _GetSignedBinaryMetadata(binary_type, relative_path):
    
    root_urn = _GetSignedBlobsRoots()[binary_type]
    binary_urn = root_urn.Add(relative_path)
    blob_iterator, timestamp = signed_binary_utils.FetchBlobsForSignedBinary(
        binary_urn)
    binary_size = 0
    has_valid_signature = True
    for blob in blob_iterator:
      binary_size += len(blob.data)
      if not has_valid_signature:
        # No need to check the signature if a previous blob had an invalid
        # signature.
        continue
      try:
        blob.Verify(config.CONFIG["Client.executable_signing_public_key"])
      except rdf_crypto.Error:
        has_valid_signature = False
  
    return ApiGrrBinary(
        path=relative_path,
        type=binary_type,
        size=binary_size,
        timestamp=timestamp,
        has_valid_signature=has_valid_signature)
docs: Fetches metadata for the given binary from the datastore.
  
    Args:
      binary_type: ApiGrrBinary.Type of the binary.
      relative_path: Relative path of the binary, relative to the canonical URN
        roots for signed binaries (see _GetSignedBlobsRoots()).
  
    Returns:
      An ApiGrrBinary RDFProtoStruct containing metadata for the binary.