Connect OpenVPN service with Flutter, Issues and PRs are very welcome!
There is no special setup in android 🤭
Add 2 capabillity on Runner's Target, App Groups and Network Extensions, Look at the image below to get clearer details
Click + button on bottom left, Choose NETWORK EXTENSION, and follow instruction's image bellow
Add Capabillity on VPNExtension, Do it same like Runner's Capabillitiy
Add the following lines to your Podfile (ios/Podfile
)
target 'VPNExtension' do
use_frameworks!
pod 'OpenVPNAdapter', :git => 'https://github.com/ss-abramchuk/OpenVPNAdapter.git', :tag => '0.8.0'
end
Open VPNExtension > PacketTunnelProvider.swift and copy paste this script PacketTunnelProvider.swift
You must use iOS Devices instead of Simulator to connect
Before start, you have to initialize the OpenVPN plugin.
late OpenVPN openvpn;
@override
void initState() {
openvpn = OpenVPN(onVpnStatusChanged: _onVpnStatusChanged, onVpnStageChanged: _onVpnStageChanged);
openvpn.initialize(
groupIdentifier: "GROUP_IDENTIFIER", ///Example 'group.com.laskarmedia.vpn'
providerBundleIdentifier: "NETWORK_EXTENSION_IDENTIFIER", ///Example 'id.laskarmedia.openvpnFlutterExample.VPNExtension'
localizedDescription: "LOCALIZED_DESCRIPTION" ///Example 'Laskarmedia VPN'
);
}
void _onVpnStatusChanged(VPNStatus? vpnStatus){
setState((){
this.status = vpnStatus;
});
}
void _onVpnStageChanged(VPNStage? stage){
setState((){
this.stage = stage;
});
}
void connect(){
openvpn.connect(config, name, username: username, password: password, bypassPackages: [], certIsRequired: false);
}
void disconnect(){
openvpn.disconnect();
}
- You can use appbundle to publish the app
- View Apple Guidelines Relating to VPN
- This plugin DOES use Encryption BUT, It uses Exempt Encryptions
☕️ ☕️ ☕️