Skip to content

Commit d97d2dd

Browse files
committed
Tests nginx resumption across cache options
1 parent da8f28f commit d97d2dd

File tree

2 files changed

+112
-1
lines changed

2 files changed

+112
-1
lines changed

rustls-libssl/tests/nginx.conf

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ http {
1010
access_log access.log;
1111

1212
server {
13+
# no resumption (default)
1314
listen 8443 ssl;
14-
server_name localhost;
1515
ssl_certificate ../../../test-ca/rsa/server.cert;
1616
ssl_certificate_key ../../../test-ca/rsa/server.key;
17+
server_name localhost;
1718

1819
location = / {
1920
return 200 "hello world\n";
@@ -44,4 +45,81 @@ http {
4445
return 200 "s-dn:$ssl_client_s_dn\ni-dn:$ssl_client_i_dn\nserial:$ssl_client_serial\nfp:$ssl_client_fingerprint\nverify:$ssl_client_verify\nv-start:$ssl_client_v_start\nv-end:$ssl_client_v_end\nv-remain:$ssl_client_v_remain\ncert:\n$ssl_client_cert\n";
4546
}
4647
}
48+
49+
server {
50+
# per-worker resumption
51+
listen 8444 ssl;
52+
ssl_session_cache builtin;
53+
ssl_certificate ../../../test-ca/rsa/server.cert;
54+
ssl_certificate_key ../../../test-ca/rsa/server.key;
55+
server_name localhost;
56+
57+
location = / {
58+
return 200 "hello world\n";
59+
}
60+
61+
location /ssl-agreed {
62+
return 200 "protocol:$ssl_protocol,cipher:$ssl_cipher\n";
63+
}
64+
65+
location /ssl-server-name {
66+
return 200 "server-name:$ssl_server_name\n";
67+
}
68+
69+
location /ssl-was-reused {
70+
return 200 "reused:$ssl_session_reused\n";
71+
}
72+
}
73+
74+
server {
75+
# per-worker & per-server resumption
76+
listen 8445 ssl;
77+
ssl_session_cache builtin shared:port8445:1M;
78+
ssl_certificate ../../../test-ca/rsa/server.cert;
79+
ssl_certificate_key ../../../test-ca/rsa/server.key;
80+
server_name localhost;
81+
82+
83+
location = / {
84+
return 200 "hello world\n";
85+
}
86+
87+
location /ssl-agreed {
88+
return 200 "protocol:$ssl_protocol,cipher:$ssl_cipher\n";
89+
}
90+
91+
location /ssl-server-name {
92+
return 200 "server-name:$ssl_server_name\n";
93+
}
94+
95+
location /ssl-was-reused {
96+
return 200 "reused:$ssl_session_reused\n";
97+
}
98+
99+
}
100+
101+
server {
102+
# per-server resumption
103+
listen 8446 ssl;
104+
ssl_session_cache shared:port8446:1M;
105+
ssl_certificate ../../../test-ca/rsa/server.cert;
106+
ssl_certificate_key ../../../test-ca/rsa/server.key;
107+
server_name localhost;
108+
109+
location = / {
110+
return 200 "hello world\n";
111+
}
112+
113+
location /ssl-agreed {
114+
return 200 "protocol:$ssl_protocol,cipher:$ssl_cipher\n";
115+
}
116+
117+
location /ssl-server-name {
118+
return 200 "server-name:$ssl_server_name\n";
119+
}
120+
121+
location /ssl-was-reused {
122+
return 200 "reused:$ssl_session_reused\n";
123+
}
124+
}
47125
}

rustls-libssl/tests/runner.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,39 @@ fn nginx() {
371371
b"hello world\n"
372372
);
373373

374+
for (port, reused) in [(8443, '.'), (8444, 'r'), (8445, 'r'), (8446, 'r')] {
375+
// multiple requests without http connection reuse
376+
// (second should be a TLS resumption if possible)
377+
assert_eq!(
378+
Command::new("curl")
379+
.env("LD_LIBRARY_PATH", "")
380+
.args([
381+
"--verbose",
382+
"--cacert",
383+
"test-ca/rsa/ca.cert",
384+
"-H",
385+
"connection: close",
386+
&format!("https://localhost:{port}/"),
387+
&format!("https://localhost:{port}/ssl-agreed"),
388+
&format!("https://localhost:{port}/ssl-server-name"),
389+
&format!("https://localhost:{port}/ssl-was-reused")
390+
])
391+
.stdout(Stdio::piped())
392+
.output()
393+
.map(print_output)
394+
.unwrap()
395+
.stdout,
396+
format!(
397+
"hello world\n\
398+
protocol:TLSv1.3,cipher:TLS_AES_256_GCM_SHA384\n\
399+
server-name:localhost\n\
400+
reused:{reused}\n"
401+
)
402+
.as_bytes(),
403+
);
404+
println!("PASS: resumption test for port={port} reused={reused}");
405+
}
406+
374407
// big download (throttled by curl to ensure non-blocking writes work)
375408
assert_eq!(
376409
Command::new("curl")

0 commit comments

Comments
 (0)