1

Here is some sample code I am using to add a VPN configuration through my app. My question is, how can I also add in a proxy configuration. In the settings app and in Apple Configurator, users can add proxy settings (automatic or manual) along with their VPN settings.

Below is some sample code I found, but I could not find the slightest clue on how to add in a proxy as well.

let manager = NEVPNManager.shared()
    manager.loadFromPreferences { (error) -> Void in
        if manager.protocolConfiguration  == nil {
            let newIPSec = NEVPNProtocolIKEv2()
            newIPSec.serverAddress = "mycompany.vpn"
            newIPSec.username = "myvpnusername"
            newIPSec.identityDataPassword = "myvpnpassword"
            newIPSec.authenticationMethod = NEVPNIKEAuthenticationMethod.none
            newIPSec.disconnectOnSleep = false

            manager.protocolConfiguration = newIPSec
            manager.isEnabled = true

            manager.saveToPreferences(completionHandler: { (error) -> Void in

            })
        }
Matt
  • 1,087
  • 1
  • 12
  • 28

1 Answers1

1

Before you call saveToPreferences, just add this :

let proxy = NEProxySettings()
proxy.autoProxyConfigurationEnabled = true
proxy.proxyAutoConfigurationURL = URL(string: "url_of_proxy.pac")
manager.protocolConfiguration.proxySettings = proxy
Witterquick
  • 6,048
  • 3
  • 26
  • 50