Library validation was inadvertent, entitlements file pulled from something else. Wasn't notarized (Distracted by docs saying command line tools can't be notarized or stapled). This tool is always run from Terminal or as a service, never double-clicked.
I did this:
% zip -j mytool.zip .../mytool
% xcrun notarytool submit mytool.zip --keychain-profile "my profile" --wait
Successfully received submission info
createdDate: 2021-12-09T15:20:09.725Z
id: myid
name: mytool.zip
status: Accepted
% xcrun notarytool log --keychain-profile "my profile" myid
{
"logFormatVersion": 1,
"jobId": "myid",
"status": "Accepted",
"statusSummary": "Ready for distribution",
"statusCode": 0,
"archiveFilename": "mytool.zip",
"uploadDate": "2021-12-09T15:20:11.851Z",
"sha256": "9d9e6ce02881e78cb9c7a54560b18894a2b4b70716656d29573413cebba64be7",
"ticketContents": [
{
"path": "mytool.zip/mytool",
"digestAlgorithm": "SHA-256",
"cdhash": "485e2c31245e1ba4975a05f46556c2f47497be96",
"arch": "x86_64"
},
{
"path": "mytool.zip/mytool",
"digestAlgorithm": "SHA-256",
"cdhash": "156a4fc6de8e02f25e39ed2999b781ca3d88ab2f",
"arch": "arm64"
}
],
"issues": null
}
(No stapling as there is none for command line tools, AFAIK.) Now I cd to a test directory and cp .../mytool . then run mytool... Killed. Same error reporting etc as originally with no notarization. This is on my same machine that it won't even run!!! (It runs fine in the original directory that is was signed in --- in the build log there is RegisterExecutionPolicyException step, not sure exactly what controls/starts that.)
Checking the system log, there are entries for each mytool startup:
EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
Exception Subtype: UNKNOWN_0x32 at 0x0000000104060000
Exception Codes: 0x0000000000000032, 0x0000000104060000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: CODESIGNING 2
But the code signing is fine:
% codesign --verify --strict -vvvv --check-notarization ./mytool
./mytool: valid on disk
./mytool: satisfies its Designated Requirement
This stuff just drives me INSANE. Not only are there way too many tools and hoops involved, the diagnostics just aren't acceptable.
If the product is signed, notarised, and stapled correctly, everything should work. If not, you’ll need to investigate why Gatekeeper is unhappy (2), fix that, and then retest.
"Fix that" !!!!!! No! Just no! There MUST be a way for Gatekeeper/spctl to render an exact description of whether or not it will run something (apps, command line tools, ...) on arbitrary customer machines, immediately, right away, from the development machine, bypassing any caching or anything else. How many thousands of 3rd party developer days need to be lost for one Apple developer to spend a few days to update spctl to produce 100% accurate and useful messaging? For example, the messaging out of notarytool was very good! It told me which of the half-dozen hoops I had to jump through next (keychains! app-specific passwords!). It just takes too too long to do the research to figure out what to do at all, only to be confronted with an inexplicable error. $237billion a year, and developers have to guess? Apple can do better. Sorry for the rant but it is necessary.