1

I'm trying to connect to a VPN, in order to have permissions to some web services that I request using HttpURLConnection. I need to enter the server and the credentials to the VPN, but I have no clue how to do that. I'm concerned that exists the vpnService but I didn't find how to use it and mainly how to pass credentials to it. Can you guys help me?

I want to establish the connection to a VPN from my university and, once did it, make the connections pass through it. I did it manually at the phone and It worked. Now I want to do it at the code so people that uses my app don't need to do that.

Edit: I just want to connect to a vpn programatically, instead of doing it through the vpn settings at android's settings menu.

  • `I didn't find how to use it` I don't think you searched correctly. Show how you searched. – Vladyslav Matviienko Nov 08 '17 at 10:01
  • Searched at google and here (stackoverflow): VPN android, VPN credentials android, VPNService android. I did find toyvpn and other solutions but I can't figure how to pass the credentials. – André Luiz Nunes Amaru Nov 08 '17 at 10:03
  • you need to add some description of what you want to do with `VPN Android` to the search request. Try googling `android vpn connection programmatically` – Vladyslav Matviienko Nov 08 '17 at 10:05
  • I just find old or not working code. Examples : https://stackoverflow.com/questions/20418353/programmatically-setting-up-a-vpn , https://git.strongswan.org/?p=strongswan.git;a=blob;f=src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java;h=a6b9fc52dcecde9af39fb5c7634a211dd815e9a9;hb=HEAD#l224 , https://git.strongswan.org/?p=strongswan.git;a=blob;f=src/frontends/android/app/src/main/jni/libandroidbridge/charonservice.c;h=fa9708963c92da9f758b4d61c8f1fdd28942bbca;hb=HEAD#l590 , http://www.thegeekstuff.com/2014/06/android-vpn-service/ – André Luiz Nunes Amaru Nov 08 '17 at 10:45
  • Following the question trail from [here](https://stackoverflow.com/q/10444757) to [here](https://stackoverflow.com/q/8921457) led me to a google issue [here](https://issuetracker.google.com/36918183). It would seem that some apps have managed to accomplish what you're asking through the use of various private or undocumented Android APIs. One method suggests the use of the [`VpnService` API](https://developer.android.com/reference/android/net/VpnService.html), which is the method used by the [StrongSwan Android VPN Client](https://wiki.strongswan.org/projects/strongswan/wiki/AndroidVPNClient). – AfroThundr Nov 28 '17 at 00:05

0 Answers0