@@ -19,31 +19,26 @@ local co_yield = coroutine._yield
19
19
local table_new = require (" table.new" )
20
20
local table_clear = require (" table.clear" )
21
21
22
- if not pcall (ffi .typeof , " ngx_ssl_session_t" ) then
23
- ffi .cdef [[
24
- typedef struct SSL_SESSION ngx_ssl_session_t ;
25
- ]]
26
- end
27
-
28
22
ffi .cdef [[
29
23
typedef struct ngx_http_lua_socket_tcp_upstream_s ngx_http_lua_socket_tcp_upstream_t ;
30
24
31
25
int ngx_http_lua_ffi_socket_tcp_tlshandshake (ngx_http_request_t * r ,
32
- ngx_http_lua_socket_tcp_upstream_t * u , ngx_ssl_session_t * sess ,
26
+ ngx_http_lua_socket_tcp_upstream_t * u , void * sess ,
33
27
int enable_session_reuse , ngx_str_t * server_name , int verify ,
34
- int ocsp_status_req , char ** errmsg );
28
+ int ocsp_status_req , void * chain , void * pkey ,
29
+ char ** errmsg );
35
30
int ngx_http_lua_ffi_socket_tcp_get_tlshandshake_result (ngx_http_request_t * r ,
36
- ngx_http_lua_socket_tcp_upstream_t * u , ngx_ssl_session_t ** sess ,
31
+ ngx_http_lua_socket_tcp_upstream_t * u , void ** sess ,
37
32
char ** errmsg , int * openssl_error_code );
38
- void ngx_http_lua_ffi_tls_free_session (ngx_ssl_session_t * sess );
33
+ void ngx_http_lua_ffi_tls_free_session (void * sess );
39
34
]]
40
35
41
36
42
37
local SOCKET_CTX_INDEX = 1
43
38
44
39
45
40
local errmsg = base .get_errmsg_ptr ()
46
- local session_ptr = ffi .new (" ngx_ssl_session_t *[1]" )
41
+ local session_ptr = ffi .new (" void *[1]" )
47
42
local server_name_str = ffi .new (" ngx_str_t[1]" )
48
43
local openssl_error_code = ffi .new (" int[1]" )
49
44
local cached_options = table_new (0 , 4 )
@@ -76,6 +71,21 @@ local function tlshandshake(self, options)
76
71
server_name_str [0 ].len = 0
77
72
end
78
73
74
+ local client_cert = options .client_cert
75
+ local client_priv_key = options .client_priv_key
76
+ if client_cert then
77
+ if not client_priv_key then
78
+ error (" client certificate supplied without "
79
+ .. " corresponding private key" , 2 )
80
+ end
81
+
82
+ if type (client_cert ) ~= " cdata"
83
+ or type (client_priv_key ) ~= " cdata"
84
+ then
85
+ error (" wrong type of client certificate or private key supplied" , 2 )
86
+ end
87
+ end
88
+
79
89
local rc =
80
90
C .ngx_http_lua_ffi_socket_tcp_tlshandshake (r , self [SOCKET_CTX_INDEX ],
81
91
session_ptr [0 ],
@@ -84,6 +94,8 @@ local function tlshandshake(self, options)
84
94
options .verify and 1 or 0 ,
85
95
options .ocsp_status_req
86
96
and 1 or 0 ,
97
+ client_cert ,
98
+ client_priv_key ,
87
99
errmsg )
88
100
89
101
if rc == FFI_NO_REQ_CTX then
0 commit comments