In TN3179 under "macOS considerations" there are a set of instances where local network privacy does not apply:
macOS automatically allows local network access by:
- Any daemon started by launchd
- Any program running as root
- Command-line tools run from Terminal or over SSH, including any child processes they spawn
I am running some tests in my app that use the local network, attempting to run them from both the terminal app and from a VScode terminal and I am getting permissions prompts. After allowing these pop ups, some of the tests still fail as if networking was blocked.
The devil is in the details here. First, this:
[quote='776479021, baxterjo, /thread/776479, /profile/baxterjo'] from a VScode terminal and I am getting permissions prompts. [/quote]
A VS Code terminal is not Terminal. The exception carved out for Terminal doesn’t apply to other terminal-ish apps.
What’ll actually happen in the VS Code case is gonna depend on how it implemented its terminal environment. It’s possible that the system will see VS Code as the responsible code for your program and thus VS Code’s Local Network privilege will apply. However, it’s also possible for programs to do things that break that responsibility chain, in which case your program will look like a tool being run in a background context. What happens then is complex.
Regardless, this is something to talk about with the VS Code folks.
Coming back to Terminal, that exception works as documented, at least in my experience. Consider my built copy of the TLSTool sample code:
% codesign -d -vvv `which TLSTool`
…
Authority=Developer ID Application: Quinn Quinn
…
There’s nothing Apple-specific about this; I built it using Xcode and signed it with a Developer ID, just like any developer could.
Running this from Terminal it’s able to connect to a local server just fine:
% TLSTool s_client -connect fluffy.local.:443 -noverify
* input stream did open
* output stream did open
* output stream has space
* protocol: TLS 1.2
* cipher: ECDHE_RSA_WITH_AES_256_GCM_SHA384
…
^C
No prompts and no need to grant Terminal the Local Network privilege. This was on macOS 15.3.1, but I’ve run similar tests on many versions of macOS 15 and Terminal has worked reliably on all of them.
Now, it is possible to do things in your code to stop this from working, but it’s hard to list all the possible ways that might happen. My advice is that you try this with a simple test program to see if you can reproduce the problem there. If you can, post some details and I’ll take another look.
Oh, there’s a few other things to check:
-
Make sure your code is signed with a stable code-signing identity, like Apple Development. Strictly speaking I don’t think that’s required in this case, but it’s a good idea generally.
-
Make sure your code has a main executable UUID, as discussed in TN3178: Checking for and resolving build UUID problems. Without that, weird things will happen.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"