Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create VPN profile on Android

Tags:

android

root

vpn

Is it possible to programmatically create VPN profile on Android (assuming that I have a rooted device)?

If is possible, how?

Thanks.

like image 450
jorjap Avatar asked Mar 15 '12 10:03

jorjap


People also ask

How do I setup a personal VPN on Android?

First, select VPN Type, choose the VPN protocol, add a name, and click on Create. You can then enter the server address, authentication and login info, and any additional network administrator settings. Click Apply and then select OK.

What is VPN profile in Mobile?

VPNs allow devices that aren't physically on a network to securely access the network. Android includes a built-in (PPTP, L2TP/IPSec, and IPSec) VPN client. Devices running Android 4.0 and later also support VPN apps.

What is a VPN profile?

VPN profiles provide Android and iOS devices with secure access to enterprise networks. One or more VPN profiles can be assigned to specific user roles or to all roles. Up to 10 profiles can be defined.


1 Answers

You should look at the com.android.settings.vpn2 package. There it uses the @hidden KeyStore methods to manipulate VPNs:

  • KeyStore.getInstance().saw(Credentials.VPN) returns an array of String VPN IDs

  • VpnProfile.decode(KeyStore.getInstance().get(Credentials.VPN + vpn_id)) gets the VPN configuration data for the given VPN ID and decodes it as a VpnProfile object.

  • VpnProfile.put(Credentials.VPN + vpn_id, someVpnProfileInstance.encode()) will create/update a VPN connection with the given ID using the settings in the VpnProfile instance.

However, you will need to execute this as the system process -- otherwise, the KeyStore instance you get will not be connected to the one that the OS uses.

If there is a way to do this without a rooted device, I'd be interested in knowing how...

P.S. - There's a similar question here: How to programmatically create a new VPN interface with Android 4.0?

like image 154
Muggles Merriweather Avatar answered Oct 18 '22 16:10

Muggles Merriweather