11

I have to connect to a WPA2 Enterprise network which only works if I don't verify the certificate. I would prefer not to do this, because this way anyone can see the MSCHAPv2 messages.

The first step to fixing this would be looking at the certificate offered by the AP, then configuring wpa_supplicant to only trust that one. But I don't know how to get the certificate. The wpa_cli "status" command doesn't show it and it's not in any logs.

I'm also curious about which SSL/TLS cipher suites are used. Is it possible to connect manually, maybe with openssl s_client?

2
  • Not verifying a certificate just means you are not connecting to the correct AP, and not much more. Dec 30, 2016 at 9:53
  • 2
    Then the incorrect AP can recover the MD4 of my password by breaking 48 bit DES 3 times, and use that hash (without even breaking MD4) to connect to the correct AP as me. This is what I'm trying to avoid.
    – stribika
    Dec 31, 2016 at 10:06

2 Answers 2

6

You could use Wireshark to dump the handshake, then convert the binary data to PEM with openssl, as suggested by @grawity in a similar question at superuser:

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 altsubject_match as well – using public CAs would be insecure otherwise, since 802.1X unfortunately does not know what "hostname" to verify against, the way e.g. HTTPS would.)

2

It is easy to do this with itself. No Wireshark is required.

  1. Disconnect
  2. Run sudo wpa_cli
  3. Connect
  4. Find the last of the giant lines that looks like <3>CTRL-EVENT-EAP-PEER-CERT depth=0 subject='/C=CA/ST=Ontario/L=Ottawa/O=University of Ottawa/CN=roam2.uottawa.ca' cert=[...] without any hash=.
  5. Copy the certificate in hex format after cert= into a new file called eduroam.hex

If you want convert it for easier viewing or usage with other applications:

  1. Convert it to .der with xxd -r -p eduroam.hex eduroam.der
  2. Convert it to .pem with openssl x509 -inform der -in eduroam.der -outform pem -out eduroam.pem
  3. View it with openssl x509 -noout -text -in eduroam.pem

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .