IPSec Protocol

IPSec (Internet Protocol Security) is a secure network protocol suite that authenticates and encrypts data packets to provide secure encrypted communication between two computers over an Internet Protocol network. Unified SDK is using system default IKEv2 device for IPSec VPN tunnel.

Adding IPSec protocol support

To start using it, set the Protocol field to the IPSec value from the Core.Model.Enums.Protocol enum when starting the VPN.

var sdk = new SDK();

var getNodesRequest = new GetNodesRequest
{
    Carrier = carrier,
    Protocol = Core.Model.Enums.Protocol.IPSec,
};

var getNodesResponse = await sdk.GetNodesAsync(getNodesRequest).ConfigureAwait(false);

var getCredentialsRequest = new GetCredentialsRequest
{
    VpnNode = getNodesResponse.VpnCountries.FirstOrDefault(),
    WithCertificate = true,
    Protocol = Core.Model.Enums.Protocol.IPSec,
    AppVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString(),
};

var getCredentialsResponse = await sdk.GetCredentialsAsync(getCredentialsRequest).ConfigureAwait(false);
// ...

When changing the VPN protocol, it's important to call the GetNodes and GetCredentials methods before invoking startVPN. This is necessary because by calling GetNodes and GetCredentials after changing the protocol and before starting the VPN, you ensure that your application has the necessary information (available nodes) and authentication details (credentials) to successfully establish a VPN connection using the desired protocol.

Last updated