I’m working on a launch daemon. I’m in the process of adding setCodeSigningRequirement
to both sides of the connection, starting with the XPC service. I’ve already made it so that the service calls setCodeSigningRequirement
on a new connection passed to the listener method of NSXPCListenerDelegate.
It works and the connection does get invalidated. The launch daemon logs stdout and stderr to a file already. So I figured that if a connection gets invalidated because of a code signing failure, it’d be nice to NSLog
this to make it easier for users to debug what’s going on, without forcing them to use Console.app.
The docs for setCodeSigningRequirement
include an example of how to capture this error on the client side, when the client calls that method. What I cannot figure out is how to capture this error on the side of the XPC service.
I could use setInvalidationHandler
, but the problem with it is that a connection can be invalidated for a myriad of reasons and the handler doesn’t know what happened. Is there perhaps an equivalent of remoteObjectProxyWithErrorHandler
but for the service side of the connection?
Is there perhaps an equivalent of remoteObjectProxyWithErrorHandler but for the service side of the connection?
Why not call -setConnectionCodeSigningRequirement:
on the NSXPCListener
itself?
Is there perhaps an equivalent of remoteObjectProxyWithErrorHandler but for the service side of the connection?
No.
Note that you can actually message from the server to the client using -remoteObjectProxyWithErrorHandler:
, but it’s unlikely to help in this case because the connection will never get to a point where you can do that [1].
ps It’s time to move away from NSLog
. For lots of hints and tips about the system log APIs, see Your Friend the System Log.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Because the requirement check, and hence the invalidation, is driven by the first message on the connection, and in this setup that’s always going to be from the client to the server.