I have a project that has the DataExtension target installed. In this extension I have a subclass of NEFilterDataProvider (the one that's created alongside the target). However, I don't know how to trigger the actual extension to start working. I have tried adding the following in application:didFinishLaunchingWIthOptions:
[[NEFilterManager sharedManager] loadFromPreferencesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) {
// This error usually does not happen.
NSLog(@"%@", error);
}
NEFilterProviderConfiguration *config = [[NEFilterProviderConfiguration alloc] init];
config.username = @"Test";
config.organization = @"Org";
config.filterBrowsers = YES;
config.filterSockets = YES;
config.serverAddress = @"Server to request new rules";
[NEFilterManager sharedManager].providerConfiguration = config;
[[NEFilterManager sharedManager] setEnabled:YES];
[[NEFilterManager sharedManager] saveToPreferencesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) {
// This always returns:
// Error Domain=NEConfigurationErrorDomain Code=10 "permission denied" UserInfo={NSLocalizedDescription=permission denied}`
NSLog(@"%@", error);
}
}];
}];
I have a suspicion I'm getting the denied permission because of Entitlements. My entitlements look like this:
DataFilterExtension
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-/
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.appIdentifier</string>
</array>
</dict>
</plist>
MainApp
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-/
<plist version="1.0">
<dict>
<key>com.apple.developer.networking.vpn.api</key>
<array>
<string>allow-vpn</string>
</array>
</dict>
</plist>
I'm not sure what to do.
I have a suspicion I'm getting the denied permission because of Entitlements.
That’s correct. To create a Network Extension provider, you need special entitlements. This was discussed at the end of WWDC 2015 Session 717 What's New in Network Extension and VPN. For more context, see this post.
<key>com.apple.developer.networking.vpn.api</key> <array> <string>allow-vpn</string> </array>
This entitlement is for Personal VPN (using NEVPNManager to set up VPN with the built-in VPN transports) and will not help when creating a Network Extension filter provider.
Finally, before deciding on a product plan here please take note of that fact that Network Extension filter providers are only supported on supervised devices.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"