Unable to access logs and data from Network extension class

Hello, i am trying to record logs in my network extension class, and then i want to read it in my application class, i.e. viewModel. However, i am unable to read the data. I have tried different ways like UserDefaults, Keychain, FileManager, NotificationCenter and CoreData. I have also used Appgroups but still there is blocker for reading data outside the scope of Extension class.

Replies

What type of Network Extension provider are you working on?

And on what platform?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo i am using Network Extension with capability of Content Filter. It is subclass from NEFilterDataProvider

On what platform? iOS? macOS?

That distinction matters, especially when it comes to accessing to the file system.

ps Another thing that matters is whether your NE provider is packaged as a appex or sysex. However, for a content filter that’s not an issue because iOS must use an appex and macOS must use a sysex. See TN3134 Network Extension provider deployment for more on that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • its iOS and is using appex.

Add a Comment

@eskimo i am on iOS and as per the documentation i have double checked the following

  1. Appgroups configuration, provisioning profile and entitlements
  2. using suitename i.e. Appgroup name to read and write data

The problem i am facing exactly is it doesn't give me access the db to do the CRUD operation.

scenario # 2: I tried Keychain and here again it got error -25291 and i was unable to write into it.

scenario #3 : CFNotificationCenter: When i attempt to post a notification so that it could send me object in viewmodel class it didn't send notification.

scenario #4: When i add logs in UserDefaults it adds into it but when i read it outside the Extension class it returns nil.

so basically the issue i am facing is mainly because of read and write permission

that's the error i am encountering:

On iOS, a content filter has two providers:

  • The filter data provider

  • The filter control provider

The filter data provider is tightly sandboxed for privacy. That restriction is called out in docs.

Earlier you wrote:

i am trying to record logs in my network extension class, and then i want to read it in my application class

Given the above, there’s no way to achieve this goal [1].


My general advice is that you log using the system log. See Your Friend the System Log. However, that won’t let you achieve this goal, because an iOS app can only read system log entries that it created.

There’s another subtle limitation here: Access to the system log in your filter data provider is determined by how it’s signed:

  • If your filter data provider is development-signed [2], it can log to the system log just fine.

  • If not, the system will not record any of its log entries.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] If you found a way to do it that would be a significant security bug!

[2] Specifically, if it is signed with the get-task-allow entitlement.

Hello @eskimo , The reason we need to be able to read the traffic is that we need to know what traffic is being blocked and/or allowed by the filter data provider in order to make adjustments as to what traffic to allow or block per application. (main reason is because we know there are many apps that have embedded browsers and we do not wish to allow all traffic for a given app) Let me know if there are other means of achieving this. Thank you Aleksandar