Skip to content

Commit aa3c82a

Browse files
committed
add type check for client cert and key
1 parent 67a6d8a commit aa3c82a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/resty/http_connect.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ local function connect(self, options)
179179
local x509 = res[2]
180180
local pkey = res[3]
181181

182+
if type(ssl_client_cert) ~= "cdata" then
183+
return nil, "bad ssl_client_cert: cdata expected, got " .. type(ssl_client_cert)
184+
end
185+
186+
if type(ssl_client_priv_key) ~= "cdata" then
187+
return nil, "bad ssl_client_priv_key: cdata expected, got " .. type(ssl_client_priv_key)
188+
end
182189

183190
-- convert from `void*` to `OPENSSL_STACK*`
184191
local cert_chain, err = chain.dup(ffi_cast("OPENSSL_STACK*", ssl_client_cert))

t/20-mtls.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ location /t {
148148
GET /t
149149
--- error_code: 200
150150
--- error_log
151-
could not set client certificate: bad client pkey type
151+
bad ssl_client_priv_key: cdata expected, got string
152152
--- response_body_unlike: hello, CN=foo@example.com,O=OpenResty,ST=California,C=US
153153
--- skip_nginx
154154
4: < 1.21.4

0 commit comments

Comments
 (0)