问题
I need to connect a Vpn programmatically in my app, but can't seem to find a way. I see VpnService, StrongSwan, OpenVpn but this seems not IPSec. How do I go about connecting to my already build IPSec and L2TP servers that have a username, password and pre shared key.
回答1:
You can not do it in the latest versions of Android. It could be done via SystemProperties.java class which has API available for these connections, but these API are now hidden in the latest Android versions due to Security risks.
However if the phone is rooted then you can use it via hacks like reflection etc to access those System properties and get everything going.
来源:https://stackoverflow.com/questions/50021979/how-to-create-ipsec-l2tp-psk-vpn-for-android