@@ -35,6 +35,7 @@ local ngx_lua_ffi_set_cert
35
35
local ngx_lua_ffi_set_priv_key
36
36
local ngx_lua_ffi_free_cert
37
37
local ngx_lua_ffi_free_priv_key
38
+ local ngx_lua_ffi_ssl_verify_client
38
39
39
40
40
41
if subsystem == ' http' then
@@ -78,6 +79,8 @@ if subsystem == 'http' then
78
79
void ngx_http_lua_ffi_free_cert (void * cdata );
79
80
80
81
void ngx_http_lua_ffi_free_priv_key (void * cdata );
82
+
83
+ int ngx_http_lua_ffi_ssl_verify_client (void * r , int depth , void * cdata , char ** err );
81
84
]]
82
85
83
86
ngx_lua_ffi_ssl_set_der_certificate =
@@ -97,6 +100,7 @@ if subsystem == 'http' then
97
100
ngx_lua_ffi_set_priv_key = C .ngx_http_lua_ffi_set_priv_key
98
101
ngx_lua_ffi_free_cert = C .ngx_http_lua_ffi_free_cert
99
102
ngx_lua_ffi_free_priv_key = C .ngx_http_lua_ffi_free_priv_key
103
+ ngx_lua_ffi_ssl_verify_client = C .ngx_http_lua_ffi_ssl_verify_client
100
104
101
105
elseif subsystem == ' stream' then
102
106
ffi .cdef [[
@@ -140,6 +144,8 @@ elseif subsystem == 'stream' then
140
144
void ngx_stream_lua_ffi_free_cert (void * cdata );
141
145
142
146
void ngx_stream_lua_ffi_free_priv_key (void * cdata );
147
+
148
+ int ngx_stream_lua_ffi_ssl_verify_client (void * r , int depth , void * cdata , char ** err );
143
149
]]
144
150
145
151
ngx_lua_ffi_ssl_set_der_certificate =
@@ -159,6 +165,7 @@ elseif subsystem == 'stream' then
159
165
ngx_lua_ffi_set_priv_key = C .ngx_stream_lua_ffi_set_priv_key
160
166
ngx_lua_ffi_free_cert = C .ngx_stream_lua_ffi_free_cert
161
167
ngx_lua_ffi_free_priv_key = C .ngx_stream_lua_ffi_free_priv_key
168
+ ngx_lua_ffi_ssl_verify_client = C .ngx_stream_lua_ffi_ssl_verify_client
162
169
end
163
170
164
171
@@ -380,6 +387,21 @@ function _M.set_priv_key(priv_key)
380
387
end
381
388
382
389
390
+ function _M .verify_client (depth , ca_certs )
391
+ local r = get_request ()
392
+ if not r then
393
+ error (" no request found" )
394
+ end
395
+
396
+ local rc = ngx_lua_ffi_ssl_verify_client (r , depth , ca_certs , errmsg )
397
+ if rc == FFI_OK then
398
+ return true
399
+ end
400
+
401
+ return nil , ffi_str (errmsg [0 ])
402
+ end
403
+
404
+
383
405
do
384
406
_M .SSL3_VERSION = 0x0300
385
407
_M .TLS1_VERSION = 0x0301
0 commit comments