MDM Configuration in network extension

Context:

We have a container app and a network extension (NEDNSProxyProvider), the app is deployed via an MDM solution and the MDM configuration is correctly pushed using the "com.apple.configuration.managed" key in NSUserDefault.default.

The container app and the network extension are part of an App Group and so they share an UserDefaults(suiteName: "...")


The network extension is installed and run automatically using some MDM configurations, so the container app could realistically never run.


Question 1) How can the network extension access the MDM configuration? we have some settings pushed by the MDM that are mandatory for the DNS proxy.


Question 2) If the network extension can't access the MDM configuration, there's a way to execute code in the container app, even in background, from the network extension? The idea was to copy the MDM configuration from UserDefault.standard to the App group shared UserDefault.


Any other solution is welcome. 🙂

Thanks



EDIT:

In the "Apple configurator 2" / Profile editor app, I can set a custom plist as "Provider configuration" in the "DNS Proxy", so I assume this set of key/values is passed to the network extension. Will I be able to read this configuration from the "options" parameter in


startProxy(options: [String: Any]? = nil, completionHandler: @escaping (Error?) -> Void)


?

Accepted Reply

I'm auto-answering to my question, just for documentation:


The solution is to add the DNS configurations to the "Provider configuration" field in the "DNS Proxy" field in the MDM profile.



This configuration is available to the network extension trough the "options" parameter in:


startProxy(options: [String: Any]? = nil, completionHandler: @escaping (Error?) -> Void)


And in the container app using


NEDNSProxyProviderProtocol().providerConfiguration

Replies

I'm auto-answering to my question, just for documentation:


The solution is to add the DNS configurations to the "Provider configuration" field in the "DNS Proxy" field in the MDM profile.



This configuration is available to the network extension trough the "options" parameter in:


startProxy(options: [String: Any]? = nil, completionHandler: @escaping (Error?) -> Void)


And in the container app using


NEDNSProxyProviderProtocol().providerConfiguration