Skip to content

Commit 5196e65

Browse files
spacewanderagentzh
authored andcommitted
tests: remove google.com relevant ssl certificate test cases.
We could not control Google's certificate, and Google don't promise their root certificate won't change, see https://pki.google.com/faq.html. > Q: What roots should we trust for connecting to Google? > A: Google may decide to have its intermediate signed by another root at any point in time, ... Because in TEST 8 we already tested passing verify case with openresty.org, here I remove TEST 11 and change TEST 12 to test with openresty.org. Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
1 parent 9ea1c06 commit 5196e65

File tree

1 file changed

+33
-138
lines changed

1 file changed

+33
-138
lines changed

t/129-ssl-socket.t

Lines changed: 33 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Test::Nginx::Socket::Lua;
44

55
repeat_each(2);
66

7-
plan tests => repeat_each() * 218;
7+
plan tests => repeat_each() * 211;
88

99
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
1010

@@ -867,54 +867,42 @@ SSL reused session
867867

868868

869869

870-
=== TEST 11: www.google.com (SSL verify passes)
870+
=== TEST 11: openresty.org: SSL verify enabled and no corresponding trusted certificates
871871
--- config
872872
server_tokens off;
873873
resolver $TEST_NGINX_RESOLVER ipv6=off;
874874
lua_ssl_trusted_certificate ../html/trusted.crt;
875-
lua_ssl_verify_depth 3;
875+
lua_ssl_verify_depth 2;
876876
location /t {
877-
#set $port 5000;
878877
set $port $TEST_NGINX_MEMCACHED_PORT;
879878

880-
content_by_lua '
881-
-- avoid flushing google in "check leak" testing mode:
882-
local counter = package.loaded.counter
883-
if not counter then
884-
counter = 1
885-
elseif counter >= 2 then
886-
return ngx.exit(503)
887-
else
888-
counter = counter + 1
889-
end
890-
package.loaded.counter = counter
879+
content_by_lua_block {
880+
local sock = ngx.socket.tcp()
881+
sock:settimeout(4000)
891882

892883
do
893-
local sock = ngx.socket.tcp()
894-
sock:settimeout(2000)
895-
local ok, err = sock:connect("www.google.com", 443)
884+
local ok, err = sock:connect("openresty.org", 443)
896885
if not ok then
897886
ngx.say("failed to connect: ", err)
898887
return
899888
end
900889

901890
ngx.say("connected: ", ok)
902891

903-
local sess, err = sock:sslhandshake(nil, "www.google.com", true)
904-
if not sess then
892+
local session, err = sock:sslhandshake(nil, "openresty.org", true)
893+
if not session then
905894
ngx.say("failed to do SSL handshake: ", err)
906895
return
907896
end
908897

909-
ngx.say("ssl handshake: ", type(sess))
898+
ngx.say("ssl handshake: ", type(session))
910899

911-
local req = "GET / HTTP/1.1\\r\\nHost: www.google.com\\r\\nConnection: close\\r\\n\\r\\n"
900+
local req = "GET / HTTP/1.1\r\nHost: openresty.org\r\nConnection: close\r\n\r\n"
912901
local bytes, err = sock:send(req)
913902
if not bytes then
914903
ngx.say("failed to send http request: ", err)
915904
return
916905
end
917-
918906
ngx.say("sent http request: ", bytes, " bytes.")
919907

920908
local line, err = sock:receive()
@@ -929,106 +917,13 @@ SSL reused session
929917
ngx.say("close: ", ok, " ", err)
930918
end -- do
931919
collectgarbage()
932-
';
920+
}
933921
}
934922

935923
--- user_files eval
936924
">>> trusted.crt
937925
$::EquifaxRootCertificate"
938926

939-
--- request
940-
GET /t
941-
--- response_body_like chop
942-
\Aconnected: 1
943-
ssl handshake: userdata
944-
sent http request: 59 bytes.
945-
received: HTTP/1.1 (?:200 OK|302 Found)
946-
close: 1 nil
947-
\z
948-
--- grep_error_log eval: qr/lua ssl (?:set|save|free) session: [0-9A-F]+/
949-
--- grep_error_log_out eval
950-
qr/^lua ssl save session: ([0-9A-F]+)
951-
lua ssl free session: ([0-9A-F]+)
952-
$/
953-
--- error_log
954-
lua ssl server name: "www.google.com"
955-
--- no_error_log
956-
SSL reused session
957-
[error]
958-
[alert]
959-
--- timeout: 5
960-
961-
962-
963-
=== TEST 12: www.google.com (SSL verify enabled and no corresponding trusted certificates)
964-
--- config
965-
server_tokens off;
966-
resolver $TEST_NGINX_RESOLVER ipv6=off;
967-
lua_ssl_trusted_certificate ../html/trusted.crt;
968-
lua_ssl_verify_depth 3;
969-
location /t {
970-
#set $port 5000;
971-
set $port $TEST_NGINX_MEMCACHED_PORT;
972-
973-
content_by_lua '
974-
-- avoid flushing google in "check leak" testing mode:
975-
local counter = package.loaded.counter
976-
if not counter then
977-
counter = 1
978-
elseif counter >= 2 then
979-
return ngx.exit(503)
980-
else
981-
counter = counter + 1
982-
end
983-
package.loaded.counter = counter
984-
985-
do
986-
local sock = ngx.socket.tcp()
987-
sock:settimeout(2000)
988-
local ok, err = sock:connect("www.google.com", 443)
989-
if not ok then
990-
ngx.say("failed to connect: ", err)
991-
return
992-
end
993-
994-
ngx.say("connected: ", ok)
995-
996-
local sess, err = sock:sslhandshake(nil, "www.google.com", true)
997-
if not sess then
998-
ngx.say("failed to do SSL handshake: ", err)
999-
return
1000-
end
1001-
1002-
ngx.say("ssl handshake: ", type(sess))
1003-
1004-
local req = "GET / HTTP/1.1\\r\\nHost: www.google.com\\r\\nConnection: close\\r\\n\\r\\n"
1005-
local bytes, err = sock:send(req)
1006-
if not bytes then
1007-
ngx.say("failed to send http request: ", err)
1008-
return
1009-
end
1010-
1011-
ngx.say("sent http request: ", bytes, " bytes.")
1012-
1013-
local line, err = sock:receive()
1014-
if not line then
1015-
ngx.say("failed to receive response status line: ", err)
1016-
return
1017-
end
1018-
1019-
ngx.say("received: ", line)
1020-
1021-
local ok, err = sock:close()
1022-
ngx.say("close: ", ok, " ", err)
1023-
end -- do
1024-
collectgarbage()
1025-
';
1026-
}
1027-
1028-
--- user_files eval
1029-
">>> trusted.crt
1030-
$::DSTRootCertificate"
1031-
1032927
--- request
1033928
GET /t
1034929
--- response_body
@@ -1038,7 +933,7 @@ failed to do SSL handshake: 20: unable to get local issuer certificate
1038933
--- grep_error_log eval: qr/lua ssl (?:set|save|free) session: [0-9A-F]+/
1039934
--- grep_error_log_out
1040935
--- error_log
1041-
lua ssl server name: "www.google.com"
936+
lua ssl server name: "openresty.org"
1042937
lua ssl certificate verify error: (20: unable to get local issuer certificate)
1043938
--- no_error_log
1044939
SSL reused session
@@ -1047,7 +942,7 @@ SSL reused session
1047942

1048943

1049944

1050-
=== TEST 13: openresty.org: passing SSL verify with multiple certificates
945+
=== TEST 12: openresty.org: passing SSL verify with multiple certificates
1051946
--- config
1052947
server_tokens off;
1053948
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -1133,7 +1028,7 @@ SSL reused session
11331028

11341029

11351030

1136-
=== TEST 14: default cipher
1031+
=== TEST 13: default cipher
11371032
--- config
11381033
server_tokens off;
11391034
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -1212,7 +1107,7 @@ SSL reused session
12121107
12131108
12141109
1215-
=== TEST 15: explicit cipher configuration
1110+
=== TEST 14: explicit cipher configuration
12161111
--- config
12171112
server_tokens off;
12181113
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -1292,7 +1187,7 @@ SSL reused session
12921187

12931188

12941189

1295-
=== TEST 16: explicit ssl protocol configuration
1190+
=== TEST 15: explicit ssl protocol configuration
12961191
--- config
12971192
server_tokens off;
12981193
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -1372,7 +1267,7 @@ SSL reused session
13721267
13731268
13741269
1375-
=== TEST 17: unsupported ssl protocol
1270+
=== TEST 16: unsupported ssl protocol
13761271
--- config
13771272
server_tokens off;
13781273
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -1449,7 +1344,7 @@ SSL reused session
14491344
14501345
14511346
1452-
=== TEST 18: openresty.org: passing SSL verify: keepalive (reuse the ssl session)
1347+
=== TEST 17: openresty.org: passing SSL verify: keepalive (reuse the ssl session)
14531348
--- config
14541349
server_tokens off;
14551350
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -1526,7 +1421,7 @@ SSL reused session
15261421
15271422
15281423
1529-
=== TEST 19: openresty.org: passing SSL verify: keepalive (no reusing the ssl session)
1424+
=== TEST 18: openresty.org: passing SSL verify: keepalive (no reusing the ssl session)
15301425
--- config
15311426
server_tokens off;
15321427
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -1606,7 +1501,7 @@ SSL reused session
16061501
16071502
16081503
1609-
=== TEST 20: downstream cosockets do not support ssl handshake
1504+
=== TEST 19: downstream cosockets do not support ssl handshake
16101505
--- config
16111506
server_tokens off;
16121507
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -1647,7 +1542,7 @@ attempt to call method 'sslhandshake' (a nil value)
16471542
16481543
16491544
1650-
=== TEST 21: unix domain ssl cosocket (no verify)
1545+
=== TEST 20: unix domain ssl cosocket (no verify)
16511546
--- http_config
16521547
server {
16531548
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -1750,7 +1645,7 @@ SSL reused session
17501645
17511646
17521647
1753-
=== TEST 22: unix domain ssl cosocket (verify)
1648+
=== TEST 21: unix domain ssl cosocket (verify)
17541649
--- http_config
17551650
server {
17561651
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -1856,7 +1751,7 @@ SSL reused session
18561751
18571752
18581753
1859-
=== TEST 23: unix domain ssl cosocket (no ssl on server)
1754+
=== TEST 22: unix domain ssl cosocket (no ssl on server)
18601755
--- http_config
18611756
server {
18621757
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock;
@@ -1946,7 +1841,7 @@ SSL reused session
19461841
19471842
19481843
1949-
=== TEST 24: lua_ssl_crl
1844+
=== TEST 23: lua_ssl_crl
19501845
--- http_config
19511846
server {
19521847
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -2045,7 +1940,7 @@ SSL reused session
20451940
20461941
20471942
2048-
=== TEST 25: multiple handshake calls
1943+
=== TEST 24: multiple handshake calls
20491944
--- config
20501945
server_tokens off;
20511946
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -2129,7 +2024,7 @@ SSL reused session
21292024
21302025
21312026
2132-
=== TEST 26: handshake timed out
2027+
=== TEST 25: handshake timed out
21332028
--- config
21342029
server_tokens off;
21352030
resolver $TEST_NGINX_RESOLVER ipv6=off;
@@ -2183,7 +2078,7 @@ SSL reused session
21832078
21842079
21852080
2186-
=== TEST 27: unix domain ssl cosocket (no gen session)
2081+
=== TEST 26: unix domain ssl cosocket (no gen session)
21872082
--- http_config
21882083
server {
21892084
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -2254,7 +2149,7 @@ SSL reused session
22542149
22552150
22562151
2257-
=== TEST 28: unix domain ssl cosocket (gen session, true)
2152+
=== TEST 27: unix domain ssl cosocket (gen session, true)
22582153
--- http_config
22592154
server {
22602155
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -2328,7 +2223,7 @@ SSL reused session
23282223
23292224
23302225
2331-
=== TEST 29: unix domain ssl cosocket (keepalive)
2226+
=== TEST 28: unix domain ssl cosocket (keepalive)
23322227
--- http_config
23332228
server {
23342229
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -2405,7 +2300,7 @@ SSL reused session
24052300
24062301
24072302
2408-
=== TEST 30: unix domain ssl cosocket (verify cert but no host name check, passed)
2303+
=== TEST 29: unix domain ssl cosocket (verify cert but no host name check, passed)
24092304
--- http_config
24102305
server {
24112306
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -2510,7 +2405,7 @@ SSL reused session
25102405
25112406
25122407
2513-
=== TEST 31: unix domain ssl cosocket (verify cert but no host name check, NOT passed)
2408+
=== TEST 30: unix domain ssl cosocket (verify cert but no host name check, NOT passed)
25142409
--- http_config
25152410
server {
25162411
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
@@ -2603,7 +2498,7 @@ SSL reused session
26032498
26042499
26052500
2606-
=== TEST 32: handshake, too many arguments
2501+
=== TEST 31: handshake, too many arguments
26072502
--- config
26082503
server_tokens off;
26092504
resolver $TEST_NGINX_RESOLVER ipv6=off;

0 commit comments

Comments
 (0)