Skip to content

Commit fd06ddd

Browse files
committed
tests: fixed a newly failing test due to openresty.org now rejecting TLSv1 connections.
1 parent b973eb2 commit fd06ddd

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

t/129-ssl-socket.t

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# vim:set ft= ts=4 sw=4 et fdm=marker:
22

33
use Test::Nginx::Socket::Lua::Stream;
4+
use Cwd qw(abs_path realpath);
5+
use File::Basename;
46

57
repeat_each(2);
68

79
plan tests => repeat_each() * 216;
810

911
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
10-
1112
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
1213
$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8';
1314
$ENV{TEST_NGINX_SERVER_SSL_PORT} ||= 12345;
15+
$ENV{TEST_NGINX_CERT_DIR} ||= dirname(realpath(abs_path(__FILE__)));
1416

1517
#log_level 'warn';
1618
log_level 'debug';
@@ -94,10 +96,8 @@ __DATA__
9496
end -- do
9597
collectgarbage()
9698
';
97-
9899
--- config
99100
server_tokens off;
100-
101101
--- stream_response_like chop
102102
\Aconnected: 1
103103
ssl handshake: userdata
@@ -1226,32 +1226,45 @@ SSL reused session
12261226

12271227

12281228
=== TEST 16: explicit ssl protocol configuration
1229+
--- http_config
1230+
server {
1231+
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock ssl;
1232+
server_name test.com;
1233+
ssl_certificate $TEST_NGINX_CERT_DIR/cert/test.crt;
1234+
ssl_certificate_key $TEST_NGINX_CERT_DIR/cert/test.key;
1235+
ssl_protocols TLSv1;
1236+
1237+
location / {
1238+
content_by_lua_block {
1239+
ngx.exit(200)
1240+
}
1241+
}
1242+
}
12291243
--- stream_server_config
1230-
resolver $TEST_NGINX_RESOLVER ipv6=off;
12311244
lua_ssl_protocols TLSv1;
12321245

12331246
content_by_lua '
12341247
local sock = ngx.socket.tcp()
12351248
sock:settimeout(2000)
12361249
12371250
do
1238-
local ok, err = sock:connect("openresty.org", 443)
1251+
local ok, err = sock:connect("unix:$TEST_NGINX_HTML_DIR/nginx.sock")
12391252
if not ok then
12401253
ngx.say("failed to connect: ", err)
12411254
return
12421255
end
12431256
12441257
ngx.say("connected: ", ok)
12451258
1246-
local session, err = sock:sslhandshake(nil, "openresty.org")
1259+
local session, err = sock:sslhandshake(nil, "test.com")
12471260
if not session then
12481261
ngx.say("failed to do SSL handshake: ", err)
12491262
return
12501263
end
12511264
12521265
ngx.say("ssl handshake: ", type(session))
12531266
1254-
local req = "GET / HTTP/1.1\\r\\nHost: openresty.org\\r\\nConnection: close\\r\\n\\r\\n"
1267+
local req = "GET / HTTP/1.1\\r\\nHost: test.com\\r\\nConnection: close\\r\\n\\r\\n"
12551268
local bytes, err = sock:send(req)
12561269
if not bytes then
12571270
ngx.say("failed to send stream request: ", err)
@@ -1273,15 +1286,13 @@ SSL reused session
12731286
end -- do
12741287
collectgarbage()
12751288
';
1276-
12771289
--- config
12781290
server_tokens off;
1279-
12801291
--- stream_response
12811292
connected: 1
12821293
ssl handshake: userdata
1283-
sent stream request: 58 bytes.
1284-
received: HTTP/1.1 302 Moved Temporarily
1294+
sent stream request: 53 bytes.
1295+
received: HTTP/1.1 200 OK
12851296
close: 1 nil
12861297

12871298
--- log_level: debug
@@ -1292,14 +1303,13 @@ lua ssl free session: ([0-9A-F]+)
12921303
$/
12931304
--- error_log eval
12941305
[
1295-
'lua ssl server name: "openresty.org"',
1296-
qr/SSL: TLSv1, cipher: "ECDHE-RSA-AES(?:256|128)-SHA\b/,
1306+
'lua ssl server name: "test.com"',
1307+
qr/SSL: TLSv1, cipher: "ECDHE-RSA-AES256-SHA (SSLv3|TLSv1)/
12971308
]
12981309
--- no_error_log
12991310
SSL reused session
13001311
[error]
13011312
[alert]
1302-
--- timeout: 5
13031313
13041314
13051315

util/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ngx-build $force $version \
1616
--with-ld-opt="-L$PCRE_LIB -L$OPENSSL_LIB -Wl,-rpath,$PCRE_LIB:$LIBDRIZZLE_LIB:$OPENSSL_LIB" \
1717
--with-http_stub_status_module \
1818
--with-http_image_filter_module \
19+
--with-http_ssl_module \
1920
--without-mail_pop3_module \
2021
--without-mail_imap_module \
2122
--without-mail_smtp_module \

0 commit comments

Comments
 (0)