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