Post

Replies

Boosts

Views

Activity

VPN profile says "update required", doesn't load properties or init packet tunnel provider
I'm setting up an app that will need to intercept all traffic on the device. Configuration is: let manager = NETunnelProviderManager() let protocolConfiguration = NETunnelProviderProtocol() protocolConfiguration.providerBundleIdentifier = "com.***.PacketTunnelProvider" protocolConfiguration.serverAddress = "VPN Server" protocolConfiguration.providerConfiguration = ["key": "value"] manager.protocolConfiguration = protocolConfiguration manager.localizedDescription = "VPN Server" The configuration is correctly saved but in the settings, the profile comes out with "Update required" and "must be updated by the developer before VPN Server can be connected" Looking around the forums, I already checked the entitlements on the binary and everything comes out good: <key>com.apple.developer.networking.networkextension</key> <array> <string>app-proxy-provider</string> <string>packet-tunnel-provider</string> </array> on the main bundle and [Key] com.apple.developer.networking.networkextension [Value] [Array] [String] app-proxy-provider [String] packet-tunnel-provider on packettunnelprovider.appex When I try to start the tunnel with func startProxyServer() { NETunnelProviderManager.loadAllFromPreferences { (managers, error) in if let error = error { print("Error loading preferences: \(error)") return } let manager = managers?.first(where: { $0.localizedDescription == "VPN Server" }) manager!.loadFromPreferences { error in if let error = error { print("Error loading preferences: \(error)") } else { do { try manager!.connection.startVPNTunnel(options: nil) print("Started tunnel.") } catch { print("Failed to start tunnel: \(error)") } } } } putting a breakpoint will show that the profile gets loaded but it lacks completely the protocol configuration. Funnily enough, I don't get an error so I get to the "Started tunnel" code branch. Of course without the protocol configuration, even if the manager is "loaded" and connection.startVPNtunnel is called, the packettunnelprovider is never initialized and nothing actually starts. Build targets are the same on both the main app and the packet tunnel provider target, and I tried lowering or raising them to no effect. How to further debug this?
7
1
782
Oct ’23