【问题标题】:I have followed all instructions but cannot get TLS 1.3 on NGINX to show我已按照所有说明进行操作,但无法在 NGINX 上显示 TLS 1.3
【发布时间】:2019-02-17 20:35:48
【问题描述】:

我正在尝试在我的服务器上启用 TLS 1.3。我在 Google 上关注了大量文章,并且在我自己的配置中拥有相同的配置设置,但我无法通过 TLS 1.2。

我在 Ubuntu 16 上。

我使用的是使用 OpenSSL 1.1.1 构建的 NGINX 1.14 版。

➜ nginx -V
nginx version: nginx/1.14.2
built with OpenSSL 1.1.1  11 Sep 2018 (running with OpenSSL 1.1.1a  20 Nov 2018)
TLS SNI support enabled

这些是我见过的支持 TLS 1.3 所需的所有软件版本。

我在测试证书时使用的是 Chrome 72 和 SSL Labs,但它总是说它在 1.2 上。

这是我的 NGINX 配置文件中与 SSL 选项相关的部分

ssl_protocols TLSv1.3 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
ssl_ecdh_curve X25519:secp256k1:secp384r1:prime256v1;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES25
ssl_session_timeout  10m;
ssl_session_cache shared:SSL:10m;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 216.146.35.35 216.146.36.36 valid=60s;
resolver_timeout 2s;

我从https://cipherli.st 获得了密码。

使用这些配置选项,我无法通过 TLS 1.2 协议。

我相信这就是我能想到的所有可能给我带来问题的东西,但我可以告诉你任何进一步的信息,你可能需要知道以帮助我解决问题。

谢谢,

克里斯

【问题讨论】:

    标签: ssl nginx


    【解决方案1】:

    在 Nginx 上启用 TLSv1.3 可能看起来很简单,但没有按应有的文档记录。 现在切入正题。诀窍是在配置的每个服务器块中包含 SSL 设置。不这样做,将导致禁用 TLSv1.3 的事实。这是有道理的,因为 tls 协议不会在第一个请求到达服务器时“升级”:

    sudo vi ssl_config

    add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header Referrer-Policy no-referrer;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-256-GCM-SHA384:TLS13-AES-128-GCM-SHA256: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 on;
    ssl_session_tickets on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_ecdh_curve auto;
    keepalive_timeout   70;
    ssl_buffer_size 1400;
    ssl_dhparam ssl/dhparam.pem;
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8 8.8.4.4 valid=86400;
    resolver_timeout 10;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    

    还有:

    server {
        server_name xxx.xxx.xxx.xxx; #Your current server ip address. It will redirect to the domain name.
        listen 80;
        listen 443 ssl http2;
        include ssl_config;
        return 301 https://example.com$request_uri;
    }
    server {
        server_name www.example.com;
        listen 80;
        listen 443 ssl http2;
        listen [::]:80;
        listen [::]:443 ssl http2;
        include ssl_config;
        # Non-www redirect
        return 301 https://example.com$request_uri;
    }
    server {
        server_name example.com;
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        root /var/www/html;
        charset UTF-8;
        include ssl_config;
    location ~* \.(jpg|jpe?g|gif|png|ico|cur|gz|svgz|mp4|ogg|ogv|webm|htc|css|js|otf|eot|svg|ttf|woff|woff2)(\?ver=[0-9.]+)?$ {
        expires max;
        add_header Access-Control-Allow-Origin '*';
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        }
        #access_log  logs/host.access.log  main;
        location ~ /.well-known/acme-challenge {
          allow all;
          root /var/www/html;
          default_type "text/plain";
        }
    location / {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
        #limit_conn num_conn 15;
        #limit_req zone=num_reqs;
        }
    error_page  404    /404.php;
    #pass the PHP scripts to FastCGI server listening on php-fpm unix socket
    location ~ \.php$ {
        try_files       $uri =404;
        fastcgi_index   index.php;
        fastcgi_pass    php:9000; #for docker.
        #fastcgi_pass   unix:/var/run/php7-fpm.sock; #for non-docker.
        fastcgi_pass_request_headers on;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_request_buffering on;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
        include fastcgi_params;
    }
    location = /robots.txt {
        access_log off;
        log_not_found off;
        }
    location ~ /\. {
        deny  all;
        access_log off;
        log_not_found off;
        }
    }
    

    现在它可以 100% 工作,使用可用的最强密码。 不久前我发表了一篇关于 how to enable TLS 1.3 in Nginx 的博文。 作为额外的奖励,从 1.18.0、1.17.10 及更高版本开始,我 maintain fresh tls1.3 enabled docker images

    【讨论】:

      【解决方案2】:

      您的ssl_protocols 应订购为TLSv1.2 TLSv1.3

      然后,您的ssl_ciphers 应该首先包含TLSv1.3 密码列表(按此顺序):

      TLS_AES_256_GCM_SHA384
      TLS_CHACHA20_POLY1305_SHA256
      TLS_AES_128_GCM_SHA256
      TLS_AES_128_CCM_8_SHA256
      TLS_AES_128_CCM_SHA256
      

      后跟您的 TLSv1.2 密码。这是tls13.iachieved.it nginx.conf 的样子:

      ssl_protocols       TLSv1.2 TLSv1.3;
      ssl_ciphers         TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_8_SHA256:TLS_AES_128_CCM_SHA256:ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
      ssl_prefer_server_ciphers on;
      

      并使用 Chrome 72 连接到它:

      以及来自网站的回应:

      Your User Agent is:  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
      Your client supports the following ciphers:  0x2a2a:TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256: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:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA:AES256-SHA:0x000a
      The negotiated cipher with this server is:  TLS_AES_256_GCM_SHA384
      

      请注意,your client supports the following ciphers 是您的网络浏览器支持的,而不是服务器。

      【讨论】:

      • 嗯,还是不行。我添加了您上面提到的密码。你的意思是让我这样做吗?我检查了提到的网站 - 我需要添加这些密码吗?
      • 是的,您需要添加上面nginx.conf 块中列出的ssl_ciphers,并将TLSv1.3 最后放在您的ssl_protocols 中。
      • 感谢您的帮助 Joe,但即使有上述建议,它仍然显示为 TLS 1.2。
      • 这是在 SO 上缺少私人消息的情况之一,但没关系。在这一点上,我的建议是简化您的 NGINX 配置,删除您的 dhparam、ecdh 曲线、OSCP 装订等,并获得最低限度的要求。 github.com/iachievedit/tls13_nginx_cosmic 有一个 nginx.conf 的模板,如果你可以看的话(忽略 LUA 位)。我敢肯定有一些微妙的事情正在发生。
      【解决方案3】:

      您是否还检查了/etc/nginx/sites-enabled/yoursite,如果您使用的是 Let's Encrypt,/etc/letsencrypt/options-ssl-nginx.conf?仅编辑/etc/nginx/nginx.conf 可能还不够。

      我今天遇到了同样的问题。对我来说,原因是我使用了letsencrypt的Certbot。它创建/etc/letsencrypt/options-ssl-nginx.conf,其中还定义了ssl-protocols。如果您不在那里调整它们,更改 /etc/nginx/nginx.conf 将无济于事。

      编辑/etc/letsencrypt/options-ssl-nginx.conf 时要小心,因为它由 Cerbot 管理。使用sudo certbot renew --dry-run 检查是否一切正常。

      为了进一步阅读,我推荐https://libre-software.net/tls-nginx/

      【讨论】:

        【解决方案4】:

        任何看到这一点的人都应该确保他们也在 nginx.conf 的默认服务器块中检查/调整协议和密码列表。

        【讨论】:

          【解决方案5】:

          尝试使用简单的 ssl 配置启动 nginx:

          ssl_protocols       TLSv1.2 TLSv1.3;
          ssl_ciphers         HIGH:!aNULL:!MD5;
          

          【讨论】:

            猜你喜欢
            • 2011-04-11
            • 1970-01-01
            • 1970-01-01
            • 2020-03-13
            • 1970-01-01
            • 1970-01-01
            • 2020-03-25
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多