authd/taskgated error -67050/-67062 on MacOS High Sierra

This error occurs when unsigned code is run. The taskgated process is the one checking if the executable is signed. In order to check, it must open the file. So to track down what is being opened by the process you can use dtruss (you may have install the Xcode command line tools to get it). Just create the following file named unsigned.pl:

#!/usr/bin/perl

use strict;
use warnings;

open my $fh, "-|", "dtruss -p `ps -ef | grep taskgated | grep -v grep | awk '{print \$2}'` -t open 2>&1";

while (my $line = <$fh>) {
        my ($file) = $line =~ /open\("(.*)\\0"/;

        next unless defined $file and -f $file;

        my $signed = qx/codesign -dvvv "$file"/;

        print $signed;
}

Which can be run like this:

sudo perl unsigned.pl

and it will spit out lines like

/path/to/executable: code object is not signed at all

You can then create a self signed cert with Keychain Access:

  1. launch the Keychain Access app
  2. go to Keychain Access > Certificate Assistance > Create a Certificate...
  3. set the name to something like codesigner
  4. set the certificate type to Code Signing
  5. create the cert

Once you have a self-signed cert you can sign the executables in the terminal with

codesign -s codesigner /path/to/executable

Note: you will see a lot of examples using -f, but that forces it to be resigned with the new cert. If you have lost access to the cert, or if the cert has expired, that might be necessary, but I try to avoid it.