<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_signature(filename):
 """ Remove invalid signatures from a binary file If the file signature is missing or valid then it will be ignored Invalid signatures are replaced with an ad-hoc signature. This is the closest you can get to removing a signature on MacOS Parameters filename : str Filepath to a binary file """

    out, err = back_tick(['codesign', '--verify', filename],
                         ret_err=True, as_str=True, raise_err=False)
    if not err:
        return # The existing signature is valid
    if 'code object is not signed at all' in err:
        return # File has no signature, and adding a new one isn't necessary

    # This file's signature is invalid and needs to be replaced
    replace_signature(filename, '-')