@@ -479,7 +479,8 @@ read SNI name from Lua: nil, type: nil
479
479
ngx. exit(ngx. ERROR)
480
480
end
481
481
}
482
- ssl_protocols TLSv1 TLSv1. 1;
482
+
483
+ ssl_protocols TLSv1. 3;
483
484
ssl_certificate .. / .. / cert/ test. crt;
484
485
ssl_certificate_key .. / .. / cert/ test. key ;
485
486
@@ -585,7 +586,7 @@ close: 1 nil
585
586
ngx. exit(ngx. ERROR)
586
587
end
587
588
}
588
- ssl_protocols TLSv1 TLSv1. 1;
589
+ ssl_protocols TLSv1 TLSv1. 1 TLSv1 . 2 ;
589
590
ssl_certificate .. / .. / cert/ test. crt;
590
591
ssl_certificate_key .. / .. / cert/ test. key ;
591
592
@@ -675,7 +676,7 @@ close: 1 nil
675
676
676
677
677
678
678
- === TEST 7 : dynamically set ssl protocol - deny TLSv1. 1
679
+ === TEST 7 : dynamically set ssl protocol - deny TLSv1. 2
679
680
-- - skip_nginx: 5 : < 1.19 . 9
680
681
-- - http_config
681
682
lua_package_path " $ TEST_NGINX_LUA_PACKAGE_PATH" ;
@@ -685,13 +686,13 @@ close: 1 nil
685
686
server_name test. com;
686
687
ssl_client_hello_by_lua_block {
687
688
local ssl_clt = require " ngx.ssl.clienthello"
688
- local ok = ssl_clt. set_protocols({" TLSv1.2 " , " TLSv1. 3" })
689
+ local ok = ssl_clt. set_protocols({" TLSv1.3" })
689
690
if not ok then
690
691
print (" failed to set_protocols" )
691
692
ngx. exit(ngx. ERROR)
692
693
end
693
694
}
694
- ssl_protocols TLSv1 TLSv1. 1;
695
+ ssl_protocols TLSv1 TLSv1. 1 TLSV1 . 2 TLSV1 . 3 ;
695
696
ssl_certificate .. / .. / cert/ test. crt;
696
697
ssl_certificate_key .. / .. / cert/ test. key ;
697
698
@@ -705,7 +706,7 @@ close: 1 nil
705
706
-- - config
706
707
server_tokens off;
707
708
lua_ssl_trusted_certificate .. / .. / cert/ test. crt;
708
- lua_ssl_protocols TLSv1. 1;
709
+ lua_ssl_protocols TLSv1. 1 TLSV1 . 2 ;
709
710
710
711
location / t {
711
712
content_by_lua_block {
@@ -772,7 +773,8 @@ failed to do SSL handshake: handshake failed
772
773
773
774
774
775
=== TEST 8 : dynamically set ssl protocol - deny TLSv1
775
- -- - skip_nginx: 5 : < 1.19 . 9
776
+ openssl3 does not support TLSv1
777
+ -- - skip_nginx: 5 : < 100.0 . 0
776
778
-- - http_config
777
779
lua_package_path " $ TEST_NGINX_LUA_PACKAGE_PATH" ;
778
780
@@ -880,15 +882,15 @@ failed to do SSL handshake: handshake failed
880
882
local types, err = ssl_clt. get_supported_versions()
881
883
if not err and types then
882
884
for _, ssl_type in pairs (types) do
883
- if ssl_type == " TLSv1.2 " then
885
+ if ssl_type == " TLSv1.3 " then
884
886
ngx. exit(ngx. OK)
885
887
end
886
888
end
887
889
end
888
890
ngx. log (ngx. ERR, " failed to get_supported_versions" )
889
891
ngx. exit(ngx. ERROR)
890
892
}
891
- ssl_protocols TLSv1 TLSv1. 1 TLSv1. 2;
893
+ ssl_protocols TLSv1 TLSv1. 1 TLSv1. 2 TLSv1 . 3 ;
892
894
ssl_certificate .. / .. / cert/ test. crt;
893
895
ssl_certificate_key .. / .. / cert/ test. key ;
894
896
@@ -902,7 +904,7 @@ failed to do SSL handshake: handshake failed
902
904
-- - config
903
905
server_tokens off;
904
906
lua_ssl_trusted_certificate .. / .. / cert/ test. crt;
905
- lua_ssl_protocols TLSv1 TLSv1. 1 ;
907
+ lua_ssl_protocols TLSv1 TLSv1. 1 TLSv1 . 2 ;
906
908
907
909
location / t {
908
910
content_by_lua_block {
@@ -964,3 +966,102 @@ failed to get_supported_versions
964
966
965
967
-- - no_error_log
966
968
[alert]
969
+
970
+
971
+
972
+ === TEST 10 : log all_extensions in the clienthello packet
973
+ -- - http_config
974
+ lua_package_path " $ TEST_NGINX_LUA_PACKAGE_PATH" ;
975
+
976
+ server {
977
+ listen 127.0 . 0. 2: $ TEST_NGINX_RAND_PORT_1 ssl;
978
+ server_name test. com;
979
+ ssl_client_hello_by_lua_block {
980
+ local ssl_clt = require " ngx.ssl.clienthello"
981
+ local all_extensions, err = ssl_clt. get_client_hello_ext_present()
982
+ if not err and all_extensions then
983
+ for i, ext in ipairs(all_extensions) do
984
+ ngx. log (ngx. INFO, i, " : TLS EXT " , ext)
985
+ end
986
+ else
987
+ ngx. log (ngx. ERR, " failed to get all_extensions" )
988
+ end
989
+ ngx. exit(ngx. ERROR)
990
+ }
991
+
992
+ ssl_protocols TLSv1 TLSv1. 1 TLSv1. 2;
993
+ ssl_certificate .. / .. / cert/ test. crt;
994
+ ssl_certificate_key .. / .. / cert/ test. key ;
995
+
996
+ server_tokens off;
997
+ location / foo {
998
+ default_type ' text/plain' ;
999
+ content_by_lua_block {ngx. status = 201 ngx. say (" foo" ) ngx. exit(201 )}
1000
+ more_clear_headers Date ;
1001
+ }
1002
+ }
1003
+ -- - config
1004
+ server_tokens off;
1005
+ lua_ssl_trusted_certificate .. / .. / cert/ test. crt;
1006
+ lua_ssl_protocols TLSv1 TLSv1. 1 TLSv1. 2;
1007
+
1008
+ location / t {
1009
+ content_by_lua_block {
1010
+ do
1011
+ local sock = ngx. socket. tcp()
1012
+
1013
+ sock: settimeout(3000 )
1014
+
1015
+ local ok , err = sock: connect(" 127.0.0.2" , $ TEST_NGINX_RAND_PORT_1 )
1016
+ if not ok then
1017
+ ngx. say (" failed to connect: " , err)
1018
+ return
1019
+ end
1020
+
1021
+ ngx. say (" connected: " , ok )
1022
+
1023
+ local sess, err = sock: sslhandshake(nil, nil, true)
1024
+ if not sess then
1025
+ ngx. say (" failed to do SSL handshake: " , err)
1026
+ return
1027
+ end
1028
+
1029
+ ngx. say (" ssl handshake: " , type(sess))
1030
+
1031
+ local req = " GET /foo HTTP/1.0\r\n Host: test.com\r\n Connection: close\r\n\r\n "
1032
+ local bytes , err = sock: send(req)
1033
+ if not bytes then
1034
+ ngx. say (" failed to send http request: " , err)
1035
+ return
1036
+ end
1037
+
1038
+ ngx. say (" sent http request: " , bytes , " bytes." )
1039
+
1040
+ while true do
1041
+ local line, err = sock: receive()
1042
+ if not line then
1043
+ -- ngx. say (" failed to receive response status line: " , err)
1044
+ break
1045
+ end
1046
+
1047
+ ngx. say (" received: " , line)
1048
+ end
1049
+
1050
+ local ok , err = sock: close()
1051
+ ngx. say (" close: " , ok , " " , err)
1052
+ end -- do
1053
+ -- collectgarbage()
1054
+ }
1055
+ }
1056
+
1057
+ -- - request
1058
+ GET / t
1059
+ -- - response_body
1060
+ connected: 1
1061
+ failed to do SSL handshake: handshake failed
1062
+ -- - error_log eval
1063
+ qr/ 1 : TLS EXT \d+ , context : ssl_client_hello_by_lua/
1064
+ -- - no_error_log
1065
+ [alert]
1066
+ [crit]
1067
+ [placeholder]
0 commit comments