I have my own running daemon application that listens to a network port and executes some different commands based on the coming request. All is working fine except when trying to execute the following codesign command.
sudo codesign --force --timestamp --options=runtime --entitlements <Entitlements File Path> --sign <Application Certificate Id> <file to sign>
Where I see an error saying errSecInternalComponent. However, when I take the same command and paste it into the terminal it works.
I have my application certificate installed under both login and System keychains and set to be Always Trust in settings.
I tried adding --keychain option to specify the keychain path for the codesign command.
Also, I made sure that both login and System keychains are unlocked during command execution.
Besides, I tried adding the following key/value pair to my daemon plist file and restarting it.
<key>SessionCreate</key>
<true/>
All of the above trials failed to fix the issue, I'm out of ideas and any help would be highly appreciated.