8

As far as I understand, wireless access points using WPA-Enterprise (i.e. WPA plus 802.1X) can send a public key certificate to a client during connection setup. The client can verify this certificate to make sure it is not connecting to a rogue AP (similar to the certificate validation in HTTPS).

Questions:

  • Did I understand this correctly?
  • If yes, is there a way to download the AP certificate? Ideally, I'd like a solution that works under Linux.

I'd like to download a self-signed certificate, to use it for verifying subsequent connection attempts. This would be simpler than asking the operator of the AP for a file.

  • I don't know a tool specifically for downloading and saving the cert, but it comes across in the clear, so you could capture it with Wireshark or tcpdump. I seem to recall seeing cert data in debug/verbose wpa_supplicant logs, so you might look at that as well. Either of these approaches may require a bit of data munging to get it from pcap/log form to a proper X.509 .cer file. – Spiff Dec 17 '14 at 1:31
8

Yes, the most common WPA-Enterprise configurations use either PEAP or TTLS, both implementing TLS over EAP over 802.1X.

Usually the certificate is already published somewhere by the network operators for exactly this purpose. It's not something the user should have to ask for.

Sadly, wpa_supplicant doesn't have an option to dump the certificates even in debug mode. (I'll update this if I find a better way.) You can still monitor the actual EAPOL authentication process, though. First, install Wireshark.

While disconnected, bring the interface up manually and start a capture on it:

$ sudo ip link set wlan0 up
$ wireshark -ki wlan0 &

Start wpa_supplicant and soon you'll see the TLS handshake:

The server will send its certificates immediately after ServerHello. Select the first such packet, then dig into:

802.1X
└─Extensible Authentication Protocol
  └─Secure Sockets Layer
    └─Handshake Protocol: Certificatte
      └─Certificates

Right-click the first instance of "Certificate (stuff)" and choose "Export selected packet bytes". Wireshark will save it as a file, in binary DER format. Repeat this for all other certificates. The topmost one (RADIUS server's) has information that you can configure in altsubject_match; the last one (root CA) should be given to wpa_supplicant as ca_cert.

Now you have a few *.crt or *.der files in binary DER format. Convert them to PEM "text" format:

openssl x509 -inform DER < mycert.der > mycert.pem

(If your wpa_supplicant is using OpenSSL as the TLS handler, you must give it the "root CA" certificate; giving it the server's certificate won't work.

Note that it's also possible that the last certificate seen in Wireshark won't be of a root CA, but only issued by one of the root CAs in your /etc/ssl/certs directory... If that's the case, be sure to set domain_suffix_match as well – otherwise, using public CAs would be insecure (802.1X unfortunately does not know what "hostname" to verify against, the way e.g. HTTPS would.)

  • Thanks for the detailed writeup. It sounds a bit complicated; but if that's the simplest way to do it, I'll try. – sleske Dec 17 '14 at 8:25
  • Yup it really worked, I've download the EAP echange with tpcpdump but worked like a charm. Funny though, my stream only had one Server Hello, Certificate, ... entry – mTorres May 22 '18 at 13:12
  • In my example the TLS message is fragmented across multiple EAP packets because it's too large (especially if it sends a bunch of large RSA certificates). It's always just one TLS ServerHello in total, though. – grawity May 22 '18 at 13:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.