ngx.ssl.clienthello的get_client_hello_ext函数无法获取到自定义的扩展字段的数据

64 views
Skip to first unread message

cool init

unread,
Jun 5, 2025, 11:44:10 AMJun 5
to openresty
nginx配置文件如下
当我修改0X4D59为0的时候可以正确获取到sni_name,通过wireshark抓包可以看到我的客户端确实传递了type为 0X4D59的自定义插件。
微信图片_20250604151540.png
            local custom_ext = ssl_clt.get_client_hello_ext(0x4D59)
            if custom_ext then
                ngx.ctx.client_hello_ext = custom_ext
                ngx.log(ngx.INFO, "got client hello ext (0x4D59): ", #custom_ext, " bytes")
            else
                ngx.log(ngx.INFO, "client did not send extension 0x4D59")
            end

Junlong Li

unread,
Jun 5, 2025, 11:47:54 AMJun 5
to openresty
有点晕。你说可以正确获取 sni_name, 标题是无法获取自定义扩展字段。到底是什么问题呢?

cool init

unread,
Jun 9, 2025, 5:53:51 AMJun 9
to openresty
在 TLS 握手过程中,客户端在 ClientHello 消息的自定义扩展类型 0x4D59(等价于十进制 19801)中携带了数据。

我尝试在 OpenResty 服务端读取该扩展的值,但未能成功获取(无论使用 0x4D59 或 19801 作为标识符)。通过抓包工具确认该扩展已由客户端正确发送。

作为对比测试,当我使用标准的 ​​SNI 扩展​​(类型 0)传递数据时,在 OpenResty 中可以通过相应的 API(如 ssl_client_hello.get_client_hello_ext(0))正确获取到值。

Junlong Li

unread,
Jun 9, 2025, 5:55:13 AMJun 9
to openresty
您可以把自定义扩展的程序代码发一个上来吗?

cool init

unread,
Jun 11, 2025, 10:05:11 AMJun 11
to openresty
客户端发送自定义扩展请求的代码demo已发布在 https://github.com/limitcool/tls-custom-ext

Junlong li

unread,
Jun 11, 2025, 11:13:07 AMJun 11
to openresty
确实是不支持。如果想支持,可以购买 OpenResty XRay的商业支持,我们会协助你们添加对应的功能。
Reply all
Reply to author
Forward
0 new messages