I am building a SystemExtension with Endpoint Security API's. It runs as a client and needs to talk to XPC service hosted by an agent. I find the SystemExtension is unable to connect to any XPC service hosted outside of it. The listener function never gets called, and the connection fails while getting the remoteObjectProxy.
The agent creates the XPC listener as follows:
The SystemExtension uses the following pseudo code to establish the connection with com.xxxx.extension.agent.xpc but fails to do so:
I can successfully establish a connection where the XPC service is hosted inside the SystemExtension, and agent connects to it to get the ES events.
Could you let me know how I can get the SystemExtension connect to the XPC service hosted outside of it? Is there limitations on how it can talk to agent outside of it?
The agent creates the XPC listener as follows:
Code Block let delegate = ServiceDelegateAgent() let listener = NSXPCListener(machServiceName: "com.xxxx.extension.agent.xpc" ) listener.delegate = delegate; listener.resume() class ServiceDelegateAgent : NSObject, NSXPCListenerDelegate { func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool { newConnection.exportedInterface = NSXPCInterface(with: AgentXPCProtocol.self) newConnection.exportedObject = AgentXPC() newConnection.resume() return true } }
The SystemExtension uses the following pseudo code to establish the connection with com.xxxx.extension.agent.xpc but fails to do so:
Code Block let connection = NSXPCConnection(machServiceName: "com.xxxx.extension.agent.xpc") connection.remoteObjectInterface = NSXPCInterface(with: AgentXPCProtocol.self) connection.resume() let service = connection.remoteObjectProxyWithErrorHandler { error in NSLog("Failed to connect: \(error)") } as? AgentXPCProtocol
I can successfully establish a connection where the XPC service is hosted inside the SystemExtension, and agent connects to it to get the ES events.
Could you let me know how I can get the SystemExtension connect to the XPC service hosted outside of it? Is there limitations on how it can talk to agent outside of it?