My plan is to run it as service (using sudo launchctl load).
Yeah, that’s what I suspected.
Given that, testing your program from Terminal using sudo is not a good idea. The issue here is that sudo switches the traditional BSD context to root but does not switch the security context. This mixed environment can cause all sorts of weird problems, especially when it comes to Security framework stuff like the keychain.
For more background on this, see the Execution Contents section of Technote 2083 Daemons and Agents.
The take-home message here is that, when testing a launchd daemon, always test it by loading it into the global context using sudo launchctl.
I decided to delete the root certificate and install it again.
It’s possible that the first time you set the trust settings for this root certificate, you only set them for your user and not globally.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"