[英]UWP Vpn AddProfileFromObjectAsync always return "other" error
I'm trying to create a new VPN profile in a universal windows app.我正在尝试在通用 windows 应用程序中创建新的 VPN 配置文件。 I am using this API .
我正在使用这个 API 。
public async void connect()
{
var connectionProfile = new VpnNativeProfile
{
AlwaysOn = true,
NativeProtocolType = VpnNativeProtocolType.IpsecIkev2,
ProfileName = "TestProfile",
RememberCredentials = true,
RequireVpnClientAppUI = true,
RoutingPolicyType = VpnRoutingPolicyType.ForceAllTrafficOverVpn,
UserAuthenticationMethod = VpnAuthenticationMethod.Eap,
TunnelAuthenticationMethod = VpnAuthenticationMethod.Eap,
};
connectionProfile.Servers.Add("192.168.1.123");
var credential = new PasswordCredential
{
UserName = "test",
Password = "test123"
};
var status = await windowsVpnManager.AddProfileFromObjectAsync(connectionProfile);
Debug.Print($"Connection status -> {status}");
}
But this code always return status "other", if i create vpn profile from setting with a same properties, it work.但是这段代码总是返回状态“其他”,如果我从具有相同属性的设置创建 vpn 配置文件,它就可以工作。
Peter Smith has already answered this issue on Microsoft Q&A here: https://learn.microsoft.com/en-us/answers/questions/1155880/uwp-vpn-addprofilefromobjectasync-always-return-ot Peter Smith 已经在 Microsoft Q&A 上回答了这个问题: https://learn.microsoft.com/en-us/answers/questions/1155880/uwp-vpn-addprofilefromobjectasync-always-return-ot
I will post a summary about the solution here as well.我也会在这里发布有关解决方案的摘要。
Answer from Perter:珀特的回答:
Please add the EapConfiguration node for your profile.请为您的配置文件添加 EapConfiguration 节点。 More information is listed here: VPNv2CSP .
此处列出了更多信息: VPNv2CSP 。
In the description of VPNv2 /ProfileName/NativeProfile/Authentication/Eap it mentions that the Eap node is required;在VPNv2 /ProfileName/NativeProfile/Authentication/Eap 的描述中提到需要 Eap 节点; the only actual required item is the Eap/Configuration.
唯一实际需要的项目是 Eap/Configuration。 There are steps for making a sample Eap configuration at EAP Configuration .
在EAP 配置中有制作示例 Eap 配置的步骤。
The code should be something like this:代码应该是这样的:
connectionProfile.EapConfiguration = "<EapHostConfig xmlns=........ (long string removed)";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.