@@ -6,6 +6,7 @@ local ngx_log = ngx.log
6
6
local ngx_WARN = ngx .WARN
7
7
local to_hex = require (" resty.string" ).to_hex
8
8
local ffi_gc = ffi .gc
9
+ local ffi_cast = ffi .cast
9
10
local string_format = string.format
10
11
11
12
--[[
@@ -167,7 +168,7 @@ local function connect(self, options)
167
168
local cert_hash
168
169
if ssl and ssl_client_cert and ssl_client_priv_key then
169
170
local status , res = xpcall (function ()
170
- local chain = require (" resty.openssl.chain" )
171
+ local chain = require (" resty.openssl.x509. chain" )
171
172
local x509 = require (" resty.openssl.x509" )
172
173
local pkey = require (" resty.openssl.pkey" )
173
174
return { chain , x509 , pkey }
@@ -178,7 +179,9 @@ local function connect(self, options)
178
179
local x509 = res [2 ]
179
180
local pkey = res [3 ]
180
181
181
- local cert_chain , err = chain .dup (ssl_client_cert )
182
+
183
+ -- convert from `void*` to `OPENSSL_STACK*`
184
+ local cert_chain , err = chain .dup (ffi_cast (" OPENSSL_STACK*" , ssl_client_cert ))
182
185
if not cert_chain then
183
186
return nil , err
184
187
end
@@ -192,7 +195,8 @@ local function connect(self, options)
192
195
return nil , err
193
196
end
194
197
195
- local key , err = pkey .new (ssl_client_priv_key )
198
+ -- convert from `void*` to `EVP_PKEY*`
199
+ local key , err = pkey .new (ffi_cast (" EVP_PKEY*" , ssl_client_priv_key ))
196
200
if not key then
197
201
return nil , err
198
202
end
@@ -214,7 +218,7 @@ local function connect(self, options)
214
218
end
215
219
216
220
else
217
- if type (res ) == " string" and ngx_re_find (res , " module 'resty\\ .openssl\\ .(chain|x509|pkey) ' not found" ) then
221
+ if type (res ) == " string" and ngx_re_find (res , " module 'resty\\ .openssl\\ ..+ ' not found" ) then
218
222
ngx_log (ngx_WARN , " can't use mTLS without module `lua-resty-openssl`, falling back to non-mTLS." .. res )
219
223
220
224
else
0 commit comments