Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. vpnManager.loadFromPreferences { (error) in
  2. if error == nil {
  3.  
  4. self.ipSecProtcol.serverAddress = "address"
  5. self.ipSecProtcol.authenticationMethod = NEVPNIKEAuthenticationMethod.certificate
  6. self.ipSecProtcol.identityData = NSData(contentsOfFile: Bundle.main.path(forResource: "client", ofType: "p12")!) as? Data
  7. self.ipSecProtcol.username = "username"
  8. self.ipSecProtcol.passwordReference = KeychainWrapper.getData("password")
  9. self.ipSecProtcol.identityDataPassword = "password"
  10. self.ipSecProtcol.useExtendedAuthentication = false
  11. self.ipSecProtcol.disconnectOnSleep = false
  12.  
  13. self.vpnManager.protocolConfiguration = self.ipSecProtcol
  14. self.vpnManager.isOnDemandEnabled = false
  15.  
  16. self.vpnManager.isEnabled = true
  17.  
  18. self.vpnManager.saveToPreferences { (savingError) in
  19.  
  20. if savingError == nil {
  21. do {
  22. try self.vpnManager.connection.startVPNTunnel()
  23. }
  24. catch {
  25. print(error.localizedDescription)
  26. }
  27. }else {
  28. print(savingError?.localizedDescription)
  29. }
  30. }
  31. } else {
  32. print(error?.localizedDescription)
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement