@@ -14,6 +14,7 @@ local error = error
1414local tonumber = tonumber
1515local errmsg = base .get_errmsg_ptr ()
1616local get_string_buf = base .get_string_buf
17+ local get_string_buf_size = base .get_string_buf_size
1718local get_size_ptr = base .get_size_ptr
1819local FFI_DECLINED = base .FFI_DECLINED
1920local FFI_OK = base .FFI_OK
@@ -66,10 +67,10 @@ void *ngx_http_lua_ffi_ssl_ctx_init(unsigned int protocols, char **err);
6667void ngx_http_lua_ffi_ssl_ctx_free (void * cdata );
6768
6869int ngx_http_lua_ffi_ssl_ctx_set_priv_key (void * cdata_ctx ,
69- void * cdata_key , char ** err );
70+ void * cdata_key , unsigned char ** err_buf , size_t err_buf_len );
7071
7172int ngx_http_lua_ffi_ssl_ctx_set_cert (void * cdata_ctx ,
72- void * cdata_cert , char ** err );
73+ void * cdata_cert , unsigned char ** err_buf , size_t err_buf_len );
7374
7475]]
7576
@@ -79,6 +80,7 @@ local _M = { version = base.version }
7980
8081local charpp = ffi .new (" char*[1]" )
8182local intp = ffi .new (" int[1]" )
83+ local err_buf = ffi .new (" unsigned char *[1]" )
8284
8385
8486function _M .clear_certs ()
@@ -297,19 +299,24 @@ function _M.create_ctx(options)
297299
298300 ctx = ffi_gc (ctx , C .ngx_http_lua_ffi_ssl_ctx_free )
299301
302+ local size = get_string_buf_size ()
303+ local buf = get_string_buf (size )
304+ err_buf [0 ] = buf
305+
300306 if options .cert ~= nil then
301- local rc = C .ngx_http_lua_ffi_ssl_ctx_set_cert (ctx ,
302- options . cert , errmsg )
307+ local rc = C .ngx_http_lua_ffi_ssl_ctx_set_cert (ctx , options . cert ,
308+ err_buf , size )
303309 if rc ~= FFI_OK then
304- return nil , ffi_str (errmsg [0 ])
310+ return nil , ffi_str (err_buf [0 ])
305311 end
306312 end
307313
308314 if options .priv_key ~= nil then
309315 local rc = C .ngx_http_lua_ffi_ssl_ctx_set_priv_key (ctx ,
310- options .priv_key , errmsg )
316+ options .priv_key ,
317+ err_buf , size )
311318 if rc ~= FFI_OK then
312- return nil , ffi_str (errmsg [0 ])
319+ return nil , ffi_str (err_buf [0 ])
313320 end
314321 end
315322
0 commit comments