Version 6 (modified by IMC linksunten, 7 years ago) (diff)


Perfect Forward Secrecy with nginx on Debian Wheezy


Perfect Forward Secrecy (PFS) is a countermeasure against surveillance programs as PRISM by the NSA or Vorratsdatenspeicherung in Europe. These programs intercept and store TLS-encrypted traffic which became known as full take in the summer of Snowden in 2013. This data can be decrypted at some point of time in the future after the TLS master key has been obtained (e.g. by a bug like heartbleed). That is, unless perfect forward secrecy is used to negotiate session keys between server and client. PFS is based on Diffie-Hellman key exchange that never sends the session key which can therefore not be intercepted. The only advantage of stealing the TLS master key when PFS is employed would therefore be a stealthy man-in-the-middle attack.

PFS needs re-keying

One word of caution: if you change your setup to PFS you should re-key your server (and obtain a new TLS certificate) or your traffic until this moment will still be vulnerable to decryption if the master TLS key will be stolen in the future.

Debian and PFS

At the time of writing there are some practical problems when running web servers on Debian. The openssl library in Debian squeeze and the apache web server in Debian wheezy are too old for PFS. But nginx web server in Debian wheezy is ready for PFS and nginx works well as TLS offloader. This document is written for nginx version 1.2.1-2.2+wheezy2 and openssl version 1.0.1e-2+deb7u6.

Choose the cipher suite

PFS is enabled simply by offering the right cipher suites. suggests the following:


From a theoretical point of view, this might be perfect. But from a practical point of view, old versions of the Internet Explorer web browser cannot use any of the above cipher suites. So a compromise might be to offer RC4 stream cipher as a fall back cipher, although even Microsoft suggests to disable RC4 where possible.

The TLS settings for nginx therefore look like this:

ssl_prefer_server_ciphers on;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1 SSLv3;

Test your setup

After you have switched on PFS you should test your setup.