UWP创建VPN连接

目前我正在试图找出,如何添加VPN配置文件并从我的通用应用程序连接到它。 我可以使用Windows.Networking.Vpn命名空间连接到现有的VPN连接。 我也可以添加一个配置文件,但找不到设置所有必需信息的方法(例如PSK)。 MS文档中没有关于此命名空间的文档。 我还看到有两种不同的配置文件名称空间: VpnNativeProfileVpnPlugInProfile 。 它们之间有什么区别? 目前我不在家,所以我不能提供我目前的代码,但如果有人可以给我一些提示,那将非常有帮助。 在其他地方是否有可用的文档?

编辑1 //这是我的示例代码

创建个人资料

 VpnManagementAgent mgr = new VpnManagementAgent(); VpnNativeProfile profile = new VpnNativeProfile() { AlwaysOn = false, NativeProtocolType = VpnNativeProtocolType.L2tp, ProfileName = "MyConnection", RememberCredentials = true, RequireVpnClientAppUI = true, RoutingPolicyType = VpnRoutingPolicyType.SplitRouting, TunnelAuthenticationMethod = VpnAuthenticationMethod.PresharedKey, UserAuthenticationMethod = VpnAuthenticationMethod.Mschapv2, }; profile.Servers.Add("vpn.example.com"); VpnManagementErrorStatus profileStatus = await mgr.AddProfileFromObjectAsync(profile); 

连接到VPN

 PasswordCredential credentials = new PasswordCredential { UserName = "username", Password = "password", }; VpnManagementErrorStatus connectStatus = await mgr.ConnectProfileWithPasswordCredentialAsync(profile, credentials); 

这有效,但我不知道在哪里或如何设置PSK。

VPN Native Profile :这是指Windows收件箱/内置VPN配置文件,可用于基于L2TP,PPTP或IKEv2的VPN

VPN插件配置文件 :指基于Windows 10 UWP的VPN插件。 这是使用Windows.networking.VPN命名空间编写的VPN应用程序。

我还看了一眼代码,可以看到似乎有一个非常明显的错过,其中没有真正的方法通过代码设置PSK。 唯一真正的解决方法是立即在设置UI中进行设置。

我将继续向Windows的VPN团队报告此消失。

文档链接: https : //docs.microsoft.com/en-us/uwp/api/windows.networking.vpn