Skip to content

Commit b0421c6

Browse files
committed
feature: check context when calling ssl.verify_client
1 parent 9562c1a commit b0421c6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ngx_stream_lua_ssl_certby.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ int
13341334
ngx_stream_lua_ffi_ssl_verify_client(ngx_stream_lua_request_t *r,
13351335
void *cdata, int depth, char **err)
13361336
{
1337+
ngx_stream_lua_ctx_t *ctx;
13371338
ngx_ssl_conn_t *ssl_conn;
13381339
ngx_stream_ssl_conf_t *sscf;
13391340
STACK_OF(X509) *chain = cdata;
@@ -1347,6 +1348,17 @@ ngx_stream_lua_ffi_ssl_verify_client(ngx_stream_lua_request_t *r,
13471348
int i;
13481349
#endif
13491350

1351+
ctx = ngx_stream_get_module_ctx(r->session, ngx_stream_lua_module);
1352+
if (ctx == NULL) {
1353+
*err = "no request ctx found";
1354+
return NGX_ERROR;
1355+
}
1356+
1357+
if (!(ctx->context & NGX_STREAM_LUA_CONTEXT_SSL_CERT)) {
1358+
*err = "API disabled in the current context";
1359+
return NGX_ERROR;
1360+
}
1361+
13501362
if (r->connection == NULL || r->connection->ssl == NULL) {
13511363
*err = "bad request";
13521364
return NGX_ERROR;

0 commit comments

Comments
 (0)