5

I need to add ssl_ciphers in my nginx config. According to https://wiki.mozilla.org/Security/Server_Side_TLS the following are recommended cipher suites (with intermediate compatibility):

Cipher suites (TLS 1.3): TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

Cipher suites (TLS 1.2): ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384

My question is quite simply: how do I add both TLS 1.3 and TLS 1.2 suites in my nginx config?

Like this?

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_prefer_server_ciphers on;

ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256';

ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
1
  • 2
    Why don't you simply use the tool prominently linked from the page your reference which provides you with the necessary configuration? Jan 3, 2020 at 22:08

2 Answers 2

6

Please note that the TLSv1.1 and TLSv1.2 parameters (1.1.13, 1.0.12) work only when OpenSSL 1.0.1 or higher is used. The TLSv1.3 parameter (1.13.0) works only when OpenSSL 1.1.1 built with TLSv1.3 support is used

ssl_protocols               TLSv1.2 TLSv1.3;
ssl_ciphers                 ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers   on;

If your config test is failed, your nginx version is not supporting tlsv1.3

$ nginx -t
nginx: [emerg] invalid value "TLSv1.3" in /etc/nginx/conf.d/<file>:34
nginx: configuration file /etc/nginx/nginx.conf test failed

Choose compatible version of nginx, if not error mean all good.

9

The Mozilla tool is a good one to get what you want. This question (and the associated answers) and the provided links are interesting too to understand how the configuration directives work.

The configuration is the following:

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;

This is the Mozilla intermediate configuration:

  • ssl_protocols TLSv1.2 TLSv1.3 enables versions 1.2 and 1.3. Note that all the ciphers of version 1.3 are automatically enabled, we have nothing to do, and also that the directive ssl_ciphers only gives ciphers for version 1.2.
  • ssl_ciphers: all the ciphers for TLS 1.2.
  • ssl_prefer_server_ciphers off: let the client choose the most performant cipher suite for their hardware configuration among the ciphers the server is offering. Cfr. Why 'ssl_prefer_server_ciphers off'?
  • If you wanted only TLS 1.3, read Nginx with only TLS1.3 cipher suites, as there is a gotcha. You could also use the tool in the answer to check which ciphers are offered, with a recent version of openssl (e.g. OpenSSL 1.1.1l 24 Aug 2021).
$ ./test_ciphers.sh <put IP here>:443
Using OpenSSL 1.1.1l 24 Aug 2021.
Using tls1_1
Testing ECDHE-ECDSA-AES256-SHA         ... NO (tlsv1 alert protocol version)
...
Using tls1_2
Testing ECDHE-ECDSA-AES256-GCM-SHA384  ... NO (sslv3 alert handshake failure)
...
Testing ECDHE-RSA-AES256-GCM-SHA384    ... YES
Testing ECDHE-RSA-CHACHA20-POLY1305    ... YES
Testing ECDHE-RSA-AES128-GCM-SHA256    ... YES
Using tls1_3
Testing TLS_AES_256_GCM_SHA384         ... YES
Testing TLS_CHACHA20_POLY1305_SHA256   ... YES
Testing TLS_AES_128_GCM_SHA256         ... YES

You must log in to answer this question.

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