1

Is it possible to extract the TLS session keys from Lighttpd so we are able to decrypt traffic captured by tcpdump?

Alternatively, we could disable PFS but we prefer not to do that.

2
  • 1
    lighttpd doesn't support this out of the box, but maybe this trick with gdb helps: security.stackexchange.com/questions/80158/…
    – Stefan
    Oct 1 '17 at 8:01
  • @Stefan: Thank you for your help. I've added an answer saying so. If you would like to write your own, I'd be happy to accept it. Oct 5 '17 at 15:03
0

you can find private key in the file referenced by entry ssl.pemfile in the file /etc/lighttpd/lighttpd.conf

The key is at the beginning before the certificate.

decrypt question was already answered here:

how-to-decrypt-ssl-traffic-with-a-packet-sniffer-when-i-have-the-private-key

Ssldump is supposed to be able to do that, but it appears to be unmaintained (in the source archive of the latest version, the date of last modification of all files are in 2002 or before) so it is quite possible that it won't support newer SSL/TLS; actually, it is highly implausible that a software from 2002 could process the new encryption formats defined in TLS 1.2 (AES/GCM). TLS 1.1 was published in 2006, and TLS 1.2 in 2008.

OpenSSL is a library that implements the protocol, but is not meant for analysing a recorded session.

You may have better chance with Wireshark, which has ample documentation on how to use it to decrypt recorded sessions.

There is an important parameter to mind: decryption of a passively recorded session (with a copy of the server private key) works only if the key exchange was of type RSA or static DH; with "DHE" and "ECDHE" cipher suites, you won't be able to decrypt such a session, even with knowledge of the server private key. In that case, you will need either the negotiated "master secret", or to use the server private key to actively intercept the connection (in a Man-in-the-Middle setup).

3
  • 1
    Thank you for your response. This technique only works when Perfect Forward Secrecy is disabled. (With PFS the private key is not enough to decrypt a TLS connection). Because I would like to do this on a live-server, I don't want to disable PFS. Sep 27 '17 at 12:04
  • If you don't like to disable PFS for any or some connections I guess the only way will be to setup a reverse proxy like nginx for TLS termination in front of your web server (same host). Then it is very easy to capture traffic between proxy and web server. Think about Man-in-the-Middle setup.
    – Rainer
    Sep 27 '17 at 12:49
  • 1
    Another technique: Firefox and Chrome dump the session keys when the environment variable SSLKEYLOGFILE is set. I was hoping for something similar in lighttpd. Sep 27 '17 at 13:28
0

Lighttpd does not support this out-of-the box.

Stefan, a developer of lighttpd, suggested checking out the following answer:

Extract pre-master keys from an openssl application

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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