Until I migrated to a new M1 machine running OSX 12, this used to work fine:
codesign --sign <cert> --force --timestamp --options runtime <binaryname>
Now, the exact same command (same cert, same binary) throws an error "errSecInternalComponent"
internal error in Code Signing subsystem
I found a vague reference that there might be some problems currently with Monterey in this regard and that
ENABLE_BITCODE=NO
might need to be used but it's not clear how to set that for CLI use like this.
Any ideas much appreaciated.
This turned out to be an issue with OSX 12+ ad-hoc signing anything compiled on it with a machine-specific signature. This made codesign fail with no useful message. Trying this on OSX11 gave a useful message about Mach-O header segment overlaps. In the end, the solution was to remove the ad-hoc signing with something like optool which made it possible to correctly sign.