NGINX enable only TLS v1.2

timbo asked:

I’m running NGINX 1.14.0 on an Ubuntu 18.04.02 LTS system with OpenSSL 1.1.1. To date, we’ve used TLSv1.3 only for our browser support, but we now have a 3rd party who wants to make an api call and they only have library support for TLSv1.2. So nginx checks the path, the presence of an auth header and then forwards:

location ~ ^/api/v2/blah {
    if ($http_authorization = '') {
        return 403;
    }
    include uwsgi_params;
    uwsgi_read_timeout 512;
    uwsgi_send_timeout 512;
    uwsgi_pass lis_django;
}

I thought it would be a simple matter of just specifying ssl_protocols TLSv1.2 TLSv1.3; in the server config but the client reported connectivity problems.

And in fact, using curl to explicitly use tlsv1.2:

curl -v --tlsv1.2 --tls-max 1.2 --location \
    --request GET https://example.com:53303/api/v2/blah' \
    --header 'Authorization: Token 606986de557cd5ca037d0.....'

produces:

Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying x.x.x.x:53303...
* TCP_NODELAY set
* Connected to example.com (x.x.x.x) port 53303 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS alert, protocol version (582):
* error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version
* Closing connection 0
curl: (35) error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version

I’ve set ssl_protocol: TLSv1.2; on all virtual servers but the problem exists. How can nginx not be supporting TLSv1.2 when it’s explicitly configured?

My answer:


TLS 1.3 has its own list of ciphers which are fixed and don’t need to be specified, but TLS 1.2 does not. You need to specify ssl_ciphers when enabling TLS 1.2 (or lower).

A minimum configuration that should work with all modern TLS 1.2 clients would be:

ssl_protocols TLSv1.3 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM,EDH+AESGCM";
# curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam
ssl_dhparam /etc/nginx/dhparam.pem;

The specified list of ciphers is used only with TLS 1.2. With TLS 1.3 the internal fixed cipher list is used.

See the Mozilla SSL Configuration Generator if you need to enable additional ciphers for compatibility with oddball clients.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.