@@ -28,6 +28,7 @@ local ngx_lua_ffi_ssl_get_client_hello_server_name
28
28
local ngx_lua_ffi_ssl_get_client_hello_ext
29
29
local ngx_lua_ffi_ssl_set_protocols
30
30
local ngx_lua_ffi_ssl_get_client_hello_ext_present
31
+ local ngx_lua_ffi_ssl_get_client_hello_ciphers
31
32
32
33
33
34
if subsystem == ' http' then
@@ -45,6 +46,9 @@ if subsystem == 'http' then
45
46
int ngx_http_lua_ffi_ssl_get_client_hello_ext_present (ngx_http_request_t * r ,
46
47
int ** extensions , size_t * extensions_len , char ** err );
47
48
/* Undefined for the stream subsystem */
49
+ int ngx_http_lua_ffi_ssl_get_client_hello_ciphers (ngx_http_request_t * r ,
50
+ int ** ciphers , size_t * cipherslen , char ** err );
51
+ /* Undefined for the stream subsystem */
48
52
]]
49
53
50
54
ngx_lua_ffi_ssl_get_client_hello_server_name =
@@ -54,6 +58,9 @@ if subsystem == 'http' then
54
58
ngx_lua_ffi_ssl_set_protocols = C .ngx_http_lua_ffi_ssl_set_protocols
55
59
ngx_lua_ffi_ssl_get_client_hello_ext_present =
56
60
C .ngx_http_lua_ffi_ssl_get_client_hello_ext_present
61
+ ngx_lua_ffi_ssl_get_client_hello_ciphers =
62
+ C .ngx_http_lua_ffi_ssl_get_client_hello_ciphers
63
+
57
64
58
65
59
66
elseif subsystem == ' stream' then
@@ -148,6 +155,41 @@ function _M.get_client_hello_ext_present()
148
155
return nil , ffi_str (errmsg [0 ])
149
156
end
150
157
158
+ -- return ciphers_table, err
159
+ -- including GREASE ciphers
160
+ function _M .get_client_hello_ciphers ()
161
+ local r = get_request ()
162
+ if not r then
163
+ error (" no request found" )
164
+ end
165
+
166
+ if ngx_phase () ~= " ssl_client_hello" then
167
+ error (" API disabled in the current context" )
168
+ end
169
+
170
+ local sizep = get_size_ptr ()
171
+
172
+ local rc = ngx_lua_ffi_ssl_get_client_hello_ciphers (r , intp ,
173
+ sizep , errmsg )
174
+ if rc == FFI_OK then
175
+ local array = intp [0 ]
176
+ local size = tonumber (sizep [0 ])
177
+ local ciphers_table = table_new (size , 0 )
178
+ for i = 0 , size - 1 , 1 do
179
+ ciphers_table [i + 1 ] = array [i ]
180
+ end
181
+
182
+ return ciphers_table
183
+ end
184
+
185
+ -- NGX_DECLINED
186
+ if rc == - 5 then
187
+ return nil
188
+ end
189
+
190
+ return nil , ffi_str (errmsg [0 ])
191
+ end
192
+
151
193
-- return ext, err
152
194
function _M .get_client_hello_ext (ext_type )
153
195
local r = get_request ()
0 commit comments