Skip to content

Commit fe6e91f

Browse files
committed
refactor: upstream connection aborted handling process & related test case
1 parent da9afdd commit fe6e91f

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/ngx_stream_lua_proxy_ssl_verifyby.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,13 @@ ngx_stream_lua_proxy_ssl_verify_aborted(void *data)
449449
ngx_log_debug0(NGX_LOG_DEBUG_STREAM, cctx->connection->log, 0,
450450
"proxy_ssl_verify_by_lua: cert verify callback aborted");
451451

452-
ngx_stream_lua_finalize_request(cctx->request, NGX_ERROR);
453-
454452
cctx->aborted = 1;
455453
cctx->connection->ssl = NULL;
454+
cctx->exit_code = 0;
455+
if (cctx->pool) {
456+
ngx_destroy_pool(cctx->pool);
457+
cctx->pool = NULL;
458+
}
456459
}
457460

458461

t/164-proxy-ssl-verify-by.t

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,3 +925,36 @@ proxy_ssl_verify_by_lua: handler return value: 0, cert verify callback exit code
925925
--- no_error_log
926926
[error]
927927
[alert]
928+
929+
930+
931+
=== TEST 23: upstream connection aborted
932+
--- stream_config
933+
server {
934+
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
935+
936+
ssl_certificate ../../cert/mtls_server.crt;
937+
ssl_certificate_key ../../cert/mtls_server.key;
938+
939+
return 'it works!\n';
940+
}
941+
--- stream_server_config
942+
proxy_pass unix:$TEST_NGINX_HTML_DIR/nginx.sock;
943+
proxy_ssl on;
944+
proxy_ssl_verify on;
945+
proxy_ssl_name example.com;
946+
proxy_ssl_certificate ../../cert/mtls_client.crt;
947+
proxy_ssl_certificate_key ../../cert/mtls_client.key;
948+
proxy_ssl_trusted_certificate ../../cert/mtls_ca.crt;
949+
proxy_ssl_session_reuse off;
950+
proxy_connect_timeout 100ms;
951+
952+
proxy_ssl_verify_by_lua_block {
953+
ngx.sleep(0.2)
954+
}
955+
--- error_log
956+
proxy_ssl_verify_by_lua: cert verify callback aborted
957+
--- no_error_log
958+
[error]
959+
[alert]
960+
--- wait: 0.5

0 commit comments

Comments
 (0)