@@ -964,3 +964,103 @@ failed to get_supported_versions
964964
965965-- - no_error_log
966966[alert]
967+
968+
969+
970+ === TEST 10 : log all_extensions in the clienthello packet
971+ -- - skip_nginx: 4 : < 1.19 . 9
972+ -- - http_config
973+ lua_package_path " $ TEST_NGINX_LUA_PACKAGE_PATH" ;
974+
975+ server {
976+ listen 127.0 . 0. 2: $ TEST_NGINX_RAND_PORT_1 ssl;
977+ server_name test. com;
978+ ssl_client_hello_by_lua_block {
979+ local ssl_clt = require " ngx.ssl.clienthello"
980+ local all_extensions, err = ssl_clt. get_client_hello_ext_present()
981+ if not err and all_extensions then
982+ for i,ext in ipairs(all_extensions) do
983+ ngx. log (ngx. ERR, i, " " , ext)
984+ end
985+ else
986+ ngx. log (ngx. ERR, " failed to get all_extensions" )
987+ ngx. exit(ngx. ERROR)
988+ end
989+ }
990+ ssl_protocols TLSv1 TLSv1. 1 TLSv1. 2;
991+ ssl_certificate .. / .. / cert/ test. crt;
992+ ssl_certificate_key .. / .. / cert/ test. key ;
993+
994+ server_tokens off;
995+ location / foo {
996+ default_type ' text/plain' ;
997+ content_by_lua_block {ngx. status = 201 ngx. say (" foo" ) ngx. exit(201 )}
998+ more_clear_headers Date ;
999+ }
1000+ }
1001+ -- - config
1002+ server_tokens off;
1003+ lua_ssl_trusted_certificate .. / .. / cert/ test. crt;
1004+ lua_ssl_protocols TLSv1 TLSv1. 1 ;
1005+
1006+ location / t {
1007+ content_by_lua_block {
1008+ do
1009+ local sock = ngx. socket. tcp()
1010+
1011+ sock: settimeout(3000 )
1012+
1013+ local ok , err = sock: connect(" 127.0.0.2" , $ TEST_NGINX_RAND_PORT_1 )
1014+ if not ok then
1015+ ngx. say (" failed to connect: " , err)
1016+ return
1017+ end
1018+
1019+ ngx. say (" connected: " , ok )
1020+
1021+ local sess, err = sock: sslhandshake(nil, nil, true)
1022+ if not sess then
1023+ ngx. say (" failed to do SSL handshake: " , err)
1024+ return
1025+ end
1026+
1027+ ngx. say (" ssl handshake: " , type(sess))
1028+
1029+ local req = " GET /foo HTTP/1.0\r\n Host: test.com\r\n Connection: close\r\n\r\n "
1030+ local bytes , err = sock: send(req)
1031+ if not bytes then
1032+ ngx. say (" failed to send http request: " , err)
1033+ return
1034+ end
1035+
1036+ ngx. say (" sent http request: " , bytes , " bytes." )
1037+
1038+ while true do
1039+ local line, err = sock: receive()
1040+ if not line then
1041+ -- ngx. say (" failed to receive response status line: " , err)
1042+ break
1043+ end
1044+
1045+ ngx. say (" received: " , line)
1046+ end
1047+
1048+ local ok , err = sock: close()
1049+ ngx. say (" close: " , ok , " " , err)
1050+ end -- do
1051+ -- collectgarbage()
1052+ }
1053+ }
1054+
1055+ -- - request
1056+ GET / t
1057+ -- - response_body
1058+ connected: 1
1059+ failed to do SSL handshake: handshake failed
1060+
1061+ -- - error_log
1062+ 1 0 , context : ssl_client_hello_by_lua
1063+
1064+ -- - no_error_log
1065+ [alert]
1066+
0 commit comments