L2TP/IPsec with Certificate and MS-CHAP v2

Mar 28, 2013 at 1:37 AM
Edited Mar 28, 2013 at 1:38 AM
I'm having some trouble to setup this small vpn client, where I need to connect to a server with l2tp/ipsec and a local certificate using ms-chap v2.

Currently using the following code:
private void Form1_Load(object sender, EventArgs e)
        {
            String PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            this.rasPhoneBook1.Open(PersonalFolder + "/vpn.pbk");

            if (this.rasPhoneBook1.Entries.Contains("hostname") == false)
            {
                RasEntry entry = RasEntry.CreateVpnEntry("hostname", "0.0.0.0", RasVpnStrategy.IkeV2First,
                RasDevice.GetDeviceByName("(L2TP)", RasDeviceType.Vpn, false));
                this.rasPhoneBook1.Entries.Add(entry);
            }
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            String PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            this.rasDialer1.PhoneBookPath = PersonalFolder + "/vpn.pbk";
            this.rasDialer1.EntryName = "hostname";
            this.rasDialer1.Credentials = new System.Net.NetworkCredential(txtUsername.ToString(), txtPassword.ToString());
            this.rasDialer1.DialAsync();
        }
Anyone can help me out ?
Coordinator
Mar 28, 2013 at 4:10 PM
Like I tell pretty much everyone having problems with creating entries, there are too many permutations to be able to say specifically what's wrong with your settings. The settings you need for your connection to work might be completely different from another person doing the exact same thing. What I would suggest is creating an entry in Windows, making sure it works, and then replicating that entry in your code.

There are some instructions here to help you with this.

Jeff