You've posted in a NetBSD forum -- your previous posts were regarding OpenBSD.
In both OSes, the
nwkey option of ifconfig(8) is to set the key for WEP, not WPA/WPA2.
If you are using NetBSD, see the
wpa_supplicant(8) man page, and the
NetBSD WPA tutorial.
If you are using OpenBSD, see the
wpakey option of the
ifconfig(8) man page.