@@ -184,63 +184,7 @@ proxy_ssl_verify_by_lua: handler return value: 0, cert verify callback exit code
184184
185185
186186
187- === TEST 6: cosocket
188- --- stream_config
189- server {
190- listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
191-
192- ssl_certificate ../../cert/mtls_server.crt;
193- ssl_certificate_key ../../cert/mtls_server.key;
194-
195- return 'it works!\n';
196- }
197- --- stream_server_config
198- proxy_pass unix:$TEST_NGINX_HTML_DIR/nginx.sock;
199- proxy_ssl on;
200- proxy_ssl_verify on;
201- proxy_ssl_name example.com;
202- proxy_ssl_certificate ../../cert/mtls_client.crt;
203- proxy_ssl_certificate_key ../../cert/mtls_client.key;
204- proxy_ssl_trusted_certificate ../../cert/mtls_ca.crt;
205- proxy_ssl_session_reuse off;
206-
207- proxy_ssl_verify_by_lua_block {
208- local sock = ngx.socket.tcp()
209-
210- sock:settimeout(2000)
211-
212- local ok, err = sock:connect("127.0.0.1", $TEST_NGINX_MEMCACHED_PORT)
213- if not ok then
214- ngx.log(ngx.ERR, "failed to connect to memc: ", err)
215- return
216- end
217-
218- local bytes, err = sock:send("flush_all\r\n")
219- if not bytes then
220- ngx.log(ngx.ERR, "failed to send flush_all command: ", err)
221- return
222- end
223-
224- local res, err = sock:receive()
225- if not res then
226- ngx.log(ngx.ERR, "failed to receive memc reply: ", err)
227- return
228- end
229-
230- print("received memc reply: ", res)
231- }
232- --- stream_response
233- it works!
234- --- error_log
235- received memc reply: OK
236- --- no_error_log
237- [error]
238- [alert]
239- --- SKIP
240-
241-
242-
243- === TEST 7: ngx.exit(0) - no yield
187+ === TEST 6: ngx.exit(0) - no yield
244188--- stream_config
245189 server {
246190 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -276,7 +220,7 @@ should never reached here
276220
277221
278222
279- === TEST 8 : ngx.exit(ngx.ERROR) - no yield
223+ === TEST 7 : ngx.exit(ngx.ERROR) - no yield
280224--- stream_config
281225 server {
282226 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -315,7 +259,7 @@ should never reached here
315259
316260
317261
318- === TEST 9 : ngx.exit(0) - yield
262+ === TEST 8 : ngx.exit(0) - yield
319263--- stream_config
320264 server {
321265 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -353,7 +297,7 @@ should never reached here
353297
354298
355299
356- === TEST 10 : ngx.exit(ngx.ERROR) - yield
300+ === TEST 9 : ngx.exit(ngx.ERROR) - yield
357301--- stream_config
358302 server {
359303 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -394,7 +338,7 @@ should never reached here
394338
395339
396340
397- === TEST 11 : lua exception - no yield
341+ === TEST 10 : lua exception - no yield
398342--- stream_config
399343 server {
400344 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -432,7 +376,7 @@ should never reached here
432376
433377
434378
435- === TEST 12 : lua exception - yield
379+ === TEST 11 : lua exception - yield
436380--- stream_config
437381 server {
438382 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -471,7 +415,7 @@ should never reached here
471415
472416
473417
474- === TEST 13 : get phase
418+ === TEST 12 : get phase
475419--- stream_config
476420 server {
477421 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -504,7 +448,7 @@ get_phase: proxy_ssl_verify
504448
505449
506450
507- === TEST 14 : simple logging (by_lua_file)
451+ === TEST 13 : simple logging (by_lua_file)
508452--- stream_config
509453 server {
510454 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -540,7 +484,7 @@ a.lua:1: proxy ssl verify by lua is running!
540484
541485
542486
543- === TEST 15 : coroutine API
487+ === TEST 14 : coroutine API
544488--- stream_config
545489 server {
546490 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -594,7 +538,7 @@ co yield: 2
594538
595539
596540
597- === TEST 16 : simple user thread wait with yielding
541+ === TEST 15 : simple user thread wait with yielding
598542--- stream_config
599543 server {
600544 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -650,7 +594,7 @@ uthread: done while loading proxy ssl verify by lua
650594
651595
652596
653- === TEST 17 : uthread (kill)
597+ === TEST 16 : uthread (kill)
654598--- stream_config
655599 server {
656600 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -709,7 +653,7 @@ uthread: failed to kill: already waited or killed while loading proxy ssl verify
709653
710654
711655
712- === TEST 18 : ngx.exit(ngx.OK) - no yield
656+ === TEST 17 : ngx.exit(ngx.OK) - no yield
713657--- stream_config
714658 server {
715659 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -748,7 +692,7 @@ should never reached here
748692
749693
750694
751- === TEST 19 : proxy_ssl_verify_by_lua* without yield API (simple logic)
695+ === TEST 18 : proxy_ssl_verify_by_lua* without yield API (simple logic)
752696--- stream_config
753697 server {
754698 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -811,7 +755,7 @@ proxy ssl verify: simple test done
811755
812756
813757
814- === TEST 20 : lua_upstream_skip_openssl_default_verify default off
758+ === TEST 19 : lua_upstream_skip_openssl_default_verify default off
815759--- stream_config
816760 server {
817761 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -849,7 +793,7 @@ qr/\[debug\] .*? SSL_do_handshake: 1/,
849793
850794
851795
852- === TEST 21 : lua_upstream_skip_openssl_default_verify on
796+ === TEST 20 : lua_upstream_skip_openssl_default_verify on
853797--- stream_config
854798 server {
855799 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -890,7 +834,7 @@ proxy_ssl_verify_by_lua: openssl default verify
890834
891835
892836
893- === TEST 22 : ngx.ctx to pass data from downstream phase to upstream phase
837+ === TEST 21 : ngx.ctx to pass data from downstream phase to upstream phase
894838--- stream_config
895839 server {
896840 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -928,7 +872,7 @@ proxy_ssl_verify_by_lua: handler return value: 0, cert verify callback exit code
928872
929873
930874
931- === TEST 23 : upstream connection aborted
875+ === TEST 22 : upstream connection aborted
932876--- stream_config
933877 server {
934878 listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -958,3 +902,68 @@ proxy_ssl_verify_by_lua: cert verify callback aborted
958902[error]
959903[alert]
960904--- wait: 0.5
905+
906+
907+
908+ === TEST 23: cosocket
909+ --- stream_config
910+ server {
911+ listen *:80;
912+
913+ return "it works!\n";
914+ }
915+
916+ server {
917+ listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
918+
919+ ssl_certificate ../../cert/mtls_server.crt;
920+ ssl_certificate_key ../../cert/mtls_server.key;
921+
922+ return 'it works!\n';
923+ }
924+ --- stream_server_config
925+ proxy_pass unix:$TEST_NGINX_HTML_DIR/nginx.sock;
926+ proxy_ssl on;
927+ proxy_ssl_verify on;
928+ proxy_ssl_name example.com;
929+ proxy_ssl_certificate ../../cert/mtls_client.crt;
930+ proxy_ssl_certificate_key ../../cert/mtls_client.key;
931+ proxy_ssl_trusted_certificate ../../cert/mtls_ca.crt;
932+ proxy_ssl_session_reuse off;
933+
934+ proxy_ssl_verify_by_lua_block {
935+ do
936+ local sock = ngx.socket.tcp()
937+ sock:settimeout(2000)
938+
939+ local ok, err = sock:connect("127.0.0.1", "80")
940+ if not ok then
941+ ngx.log(ngx.ERR, "failed to connect: ", err)
942+ return
943+ end
944+
945+ ngx.log(ngx.INFO, "connected: ", ok)
946+
947+ while true do
948+ local line, err = sock:receive()
949+ if not line then
950+ -- ngx.log(ngx.ERR, "failed to receive response status line: ", err)
951+ break
952+ end
953+ ngx.log(ngx.INFO, "received: ", line)
954+ end
955+
956+ local ok, err = sock:close()
957+ ngx.log(ngx.INFO, "close: ", ok, " ", err)
958+ end -- do
959+ -- collectgarbage()
960+ }
961+ --- stream_response
962+ it works!
963+ --- error_log
964+ connected: 1
965+ received: it works!
966+ close: 1 nil
967+ --- no_error_log
968+ [error]
969+ [alert]
0 commit comments