V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
hazy
V2EX  ›  NGINX

网站无法开启 TLS1.3 问题探索

  •  
  •   hazy · 2022-04-19 15:25:59 +08:00 · 2189 次点击
    这是一个创建于 731 天前的主题,其中的信息可能已经有所发展或是发生改变。

    昨天尝鲜 Google 公共证书后照例打开 F12 欣赏下证书,结果在安全页发现使用的是 TLS1.2 连接:

    using TLS1.2, ECDHE_RAS with X25519, and AES_256_GCM.
    

    也在 ssllabs 上反复确认了不支持 TLS1.3 ,但我记得很久以前专门研究配置过是 TLS1.3 的,而且同样配置的另一台 VPS 上的网站也能开始 TLS1.3 ,就很迷惑...

    环境如下:

    • Debian 11.3
    • Nginx v1.20.2
    • openssl 1.1.1n

    编译配置:

    ./configure \
            --prefix=/etc/nginx \
            --with-openssl=../openssl-1.1.1n \
            --with-openssl-opt='enable-tls1_3' \
            --with-http_v2_module \
            --with-http_ssl_module \
            --with-http_gzip_static_module \
            --with-http_stub_status_module \
            --with-http_sub_module \
            --with-http_realip_module \
            --with-stream \
            --with-stream_ssl_module \
            --with-stream_ssl_preread_module \
    

    SSL 配置:

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDH+CHACHA20:ECDH+AESGCM+AES256;
    ssl_prefer_server_ciphers off;
    

    昨天折腾了一晚也没发现问题所在,直到今天打开了 nginx.conf 文件仔细比对,发现去年加上了一行奇怪的东西:

    server {
            listen 443 ssl default_server;
            # return 444;
            ssl_reject_handshake on;
    }
    

    ssl_reject_handshake 是 Nginx 1.19.4 引入的新特性,用来 block 未指定的 SSL 握手,以前不知道在哪里看到一个安全问题后加上的,可以避免在 IP 访问时通过证书暴露域名,试着删除之后,TLS1.3 终于回来了。

    顺着关键词搜了下发现我不是一个人: https://stackoverflow.com/questions/71023951/ssl-alert-number-70-with-tlsv1-3

    但应该是在 OpenSSL 1.1.1h 修复了,但...不过问题解决了就好,不然逼死强迫症...

    5 条回复    2022-04-19 20:23:09 +08:00
    ab
        1
    ab  
       2022-04-19 15:39:20 +08:00
    OpenSSL 1.1.1n 15 Mar 2022
    配置和你一样,TLS1.3 无问题,而且我很暴力的同时加了 80

    server
    {
    listen 80 default_server;
    listen 443 ssl http2 default_server;
    server_name _;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_reject_handshake on;
    access_log off;
    return 444;
    }
    ab
        2
    ab  
       2022-04-19 15:40:52 +08:00   ❤️ 1
    ssl_protocols TLSv1.2 TLSv1.3;

    这行加在 ssl_reject_handshake on; 下面,再试试?
    hazy
        3
    hazy  
    OP
       2022-04-19 16:19:18 +08:00
    @ab #2 感谢老哥指教,完美解决问题,我居然没想到,还是太年轻了哈哈
    1265578519
        4
    1265578519  
       2022-04-19 17:14:13 +08:00   ❤️ 1
    nginx 无法启用 tls1.3 的握手失败解决办法,openssl 1.1.1h bug
    https://bbs.itzmx.com/forum.php?mod=viewthread&tid=97997&fromuid=1

    网上一搜不是有解决办法
    Showfom
        5
    Showfom  
       2022-04-19 20:23:09 +08:00   ❤️ 2
    Nginx 默认的 TLS 协议会先遵守 default_server;

    所以你得同时加上

    ssl_protocols TLSv1.2 TLSv1.3;

    就可以解决了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   934 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:55 · PVG 03:55 · LAX 12:55 · JFK 15:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.