I am working on an MacOS app that I don't plan on releasing it via the app store. So basically it's not sandboxed.
I am using Packet Tunnel as a System extension. I do send the packets from System extension to the App side. I am reusing part of the iOS code base and trying to make it work on the MacOS App. On the iOS side I was using CFMessagePorts to send packets from the Network Extension to the Application, and basically that involved using App Groups as the port name.
So on the mac side, since the app is not sandboxed my understanding is that I don't need to use App groups at all. If the app's bundle id is com.example.transparentproxy then by using the following line, it should create a port
var remotePort : CFMessagePort? = CFMessagePortCreateRemote(kCFAllocatorDefault, "com.example.transparentproxy.out" as CFString)
But it doesn't. It returns nil. The only log that I see corresponding to this in the console is
taskgated-helper Couldn't read values in CFPrefsPlistSource<0x7fa2f3f2e040> (Domain: kCFPreferencesAnyApplication, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: No): accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access
've made sure I don't have sandbox access on SystemExtension, nor sandbox access on the App itself. Any idea as to how to debug this or if my understanding of sandbox access on System Extension is wrong.
Using the System extension, I did access a file and write to it and it did work. If the System extension is not sandboxed I should be able to create a port remotely right?
var localPort : CFMessagePort? = CFMessagePortCreateLocal(kCFAllocatorDefault, "com.example.transparentproxy.in" as CFString, nil, nil, nil)
I can create a port locally. since the above line does return an object. But it's just the remote port that keeps returning nil.
Also I had added this entitlement to the entitlements of both the app and extension :
<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<array>
<string>com.example.transparentproxy.out</string>
<string>com.example.transparentproxy.in</string>
</array>
<key>com.apple.security.temporary-exception.mach-register.global-name</key>
<array>
<string>com.example.transparentproxy.out</string>
<string>com.example.transparentproxy.in</string>
</array>