Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
903 views
in Technique[技术] by (71.8m points)

java - How to establish a VPN connection (Cisco IPSec Xauth PSK) within my android app instead of activating it through Android's inbuilt VPN tool?

I am developing an app where I have to connect to a remote server through VPN. Presently I am using Android's inbuilt tool for VPN configuration and connection (Settings>More>VPN>...), which I have to activate and deactivate several times during the use of the app (the server blocks other internet connection when connected though this VPN, so I only want to establish it once in a while).

Here is the configuration necessary for that VPN connection: Name: arbitrary Type: IPSec Xauth PSK Server Address: known IPSec Identifier: known IPSec Pre-shared key: known Username: known Password: known

If I understood right, I could either run a background service to establish the connection and then activate/deactivate from the foreground/UI activity, or maybe just have an inbuilt method if that activity/class to establish the VPN connection when necessary.

I also know there is VpnService class but I think it is much more complex than what I need. I have seen suggestions on using OpenVPN source code but I get lost on where to pick it up. This as an example: Android: Sample Code to connect to VPN in Android 4.0 using VPNService API

Is it possible to have this inbuilt VPN? Could someone give me a hint on how to code it? Thanks in advance

EDIT: I also have found here that it is not possible configure an L2TP/IPSec, would it also apply to IPSec Xauth PSK?? Create L2TP/IPSec VPN base on VpnService programmatically in Android

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...