antony darkins

antony darkins

  • NA
  • 6
  • 3.8k

Connecting to a wpa2 secured wireless router

Jan 10 2013 4:02 AM
I am trying to connect to a netgear wireless router that is secured via wpa2. 


I am using native wifi to acheive this and the code works fine if i set the router to open (no security). The error i am getting is 1388 (security descriptor is invalid). The error originated from the wlansetprofile command. Below is the profile i am using :

profileXml = string.Format("<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>NETGEAR</name><SSIDConfig><SSID><hex>4E455447454152</hex><name>NETGEAR</name></SSID><nonBroadcast>true</nonBroadcast></SSIDConfig><connectionType>ESS</connectionType><connectionMode>auto</connectionMode><autoSwitch>false</autoSwitch><MSM><security><authEncryption><authentication>WPA2PSK</authentication><encryption>AES</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>passPhrase</keyType><protected>true</protected><keyMaterial>01000000D08C9DDF0115D1118C7A00C04FC297EB01000000C169857550173C48840A6F85B52D5725000000000200000000001066000000010000200000008C6A221DAE56386A4D25F2CAAC4D6EC03EFB383DD3FD0E9321BD984A720838B4000000000E800000000200002000000009175207A7C61390B13420D334C04C22EDF95276F35A2693961D1F41B2DCD9F410000000601B2263E80EE0EC77CE8A0879D4F241400000008DED98FF06D0999F18738BADB44608C7C6B7E5DBCDA8ECD90682F993EE1226D447ED5A97797E615FE0C9BA0B8F2285E9ACB1AB0646D8C46BDF76BC35C2837D3C</keyMaterial></sharedKey></security></MSM></WLANProfile>");//);

the key material was obtained from a profile created by windows then using netsh wlan export profile to retrieve it.

many thanks in advance for your time