]>
Commit | Line | Data |
---|---|---|
ce2cdac2 EK |
1 | # -*- mode: perl; -*- |
2 | # Copyright 2016-2016 The OpenSSL Project Authors. All Rights Reserved. | |
3 | # | |
909f1a2e | 4 | # Licensed under the Apache License 2.0 (the "License"). You may not use |
ce2cdac2 EK |
5 | # this file except in compliance with the License. You can obtain a copy |
6 | # in the file LICENSE in the source distribution or at | |
7 | # https://www.openssl.org/source/license.html | |
8 | ||
9 | ||
0f1e51ea | 10 | ## Test NPN. Note that NPN is only supported up to TLSv1.2 |
ce2cdac2 EK |
11 | |
12 | use strict; | |
13 | use warnings; | |
14 | ||
15 | package ssltests; | |
16 | ||
ce2cdac2 EK |
17 | our @tests = ( |
18 | { | |
19 | name => "npn-simple", | |
9f48bbac EK |
20 | server => { |
21 | extra => { | |
22 | "NPNProtocols" => "foo", | |
23 | }, | |
24 | }, | |
25 | client => { | |
26 | extra => { | |
27 | "NPNProtocols" => "foo", | |
28 | }, | |
0f1e51ea | 29 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 30 | }, |
ce2cdac2 | 31 | test => { |
2ac6bdc0 | 32 | "ExpectedNPNProtocol" => "foo", |
ce2cdac2 EK |
33 | }, |
34 | }, | |
35 | { | |
36 | name => "npn-client-finds-match", | |
9f48bbac EK |
37 | server => { |
38 | extra => { | |
39 | "NPNProtocols" => "baz,bar", | |
40 | }, | |
41 | }, | |
42 | client => { | |
43 | extra => { | |
44 | "NPNProtocols" => "foo,bar", | |
45 | }, | |
0f1e51ea | 46 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 47 | }, |
ce2cdac2 | 48 | test => { |
2ac6bdc0 | 49 | "ExpectedNPNProtocol" => "bar", |
ce2cdac2 EK |
50 | }, |
51 | }, | |
52 | { | |
53 | name => "npn-client-honours-server-pref", | |
9f48bbac EK |
54 | server => { |
55 | extra => { | |
56 | "NPNProtocols" => "bar,foo", | |
57 | }, | |
58 | }, | |
59 | client => { | |
60 | extra => { | |
61 | "NPNProtocols" => "foo,bar", | |
62 | }, | |
0f1e51ea | 63 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 64 | }, |
ce2cdac2 | 65 | test => { |
2ac6bdc0 | 66 | "ExpectedNPNProtocol" => "bar", |
ce2cdac2 EK |
67 | }, |
68 | }, | |
69 | { | |
70 | name => "npn-client-first-pref-on-mismatch", | |
9f48bbac EK |
71 | server => { |
72 | extra => { | |
73 | "NPNProtocols" => "baz", | |
74 | }, | |
75 | }, | |
76 | client => { | |
77 | extra => { | |
78 | "NPNProtocols" => "foo,bar", | |
79 | }, | |
0f1e51ea | 80 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 81 | }, |
ce2cdac2 | 82 | test => { |
2ac6bdc0 | 83 | "ExpectedNPNProtocol" => "foo", |
ce2cdac2 EK |
84 | }, |
85 | }, | |
86 | { | |
87 | name => "npn-no-server-support", | |
0f1e51ea | 88 | server => {}, |
9f48bbac EK |
89 | client => { |
90 | extra => { | |
91 | "NPNProtocols" => "foo", | |
92 | }, | |
0f1e51ea | 93 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 94 | }, |
ce2cdac2 | 95 | test => { |
2ac6bdc0 | 96 | "ExpectedNPNProtocol" => undef, |
ce2cdac2 EK |
97 | }, |
98 | }, | |
99 | { | |
100 | name => "npn-no-client-support", | |
9f48bbac EK |
101 | server => { |
102 | extra => { | |
103 | "NPNProtocols" => "foo", | |
104 | }, | |
105 | }, | |
0f1e51ea MC |
106 | client => { |
107 | "MaxProtocol" => "TLSv1.2" | |
108 | }, | |
ce2cdac2 | 109 | test => { |
2ac6bdc0 | 110 | "ExpectedNPNProtocol" => undef, |
ce2cdac2 EK |
111 | }, |
112 | }, | |
113 | { | |
114 | name => "npn-with-sni-no-context-switch", | |
9f48bbac EK |
115 | server => { |
116 | extra => { | |
117 | "NPNProtocols" => "foo", | |
118 | "ServerNameCallback" => "IgnoreMismatch", | |
119 | }, | |
120 | }, | |
121 | server2 => { | |
122 | extra => { | |
123 | "NPNProtocols" => "bar", | |
124 | }, | |
125 | }, | |
126 | client => { | |
127 | extra => { | |
128 | "NPNProtocols" => "foo,bar", | |
129 | "ServerName" => "server1", | |
130 | }, | |
0f1e51ea | 131 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 132 | }, |
ce2cdac2 | 133 | test => { |
2ac6bdc0 EK |
134 | "ExpectedServerName" => "server1", |
135 | "ExpectedNPNProtocol" => "foo", | |
ce2cdac2 EK |
136 | }, |
137 | }, | |
138 | { | |
139 | name => "npn-with-sni-context-switch", | |
9f48bbac EK |
140 | server => { |
141 | extra => { | |
142 | "NPNProtocols" => "foo", | |
143 | "ServerNameCallback" => "IgnoreMismatch", | |
144 | }, | |
145 | }, | |
146 | server2 => { | |
147 | extra => { | |
148 | "NPNProtocols" => "bar", | |
149 | }, | |
150 | }, | |
151 | client => { | |
152 | extra => { | |
153 | "NPNProtocols" => "foo,bar", | |
154 | "ServerName" => "server2", | |
155 | }, | |
0f1e51ea | 156 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 157 | }, |
ce2cdac2 | 158 | test => { |
2ac6bdc0 EK |
159 | "ExpectedServerName" => "server2", |
160 | "ExpectedNPNProtocol" => "bar", | |
ce2cdac2 EK |
161 | }, |
162 | }, | |
163 | { | |
164 | name => "npn-selected-sni-server-supports-npn", | |
9f48bbac EK |
165 | server => { |
166 | extra => { | |
167 | "ServerNameCallback" => "IgnoreMismatch", | |
168 | }, | |
169 | }, | |
170 | server2 => { | |
171 | extra => { | |
172 | "NPNProtocols" => "bar", | |
173 | }, | |
174 | }, | |
175 | client => { | |
176 | extra => { | |
177 | "NPNProtocols" => "foo,bar", | |
178 | "ServerName" => "server2", | |
179 | }, | |
0f1e51ea | 180 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 181 | }, |
ce2cdac2 | 182 | test => { |
2ac6bdc0 EK |
183 | "ExpectedServerName" => "server2", |
184 | "ExpectedNPNProtocol" => "bar", | |
ce2cdac2 EK |
185 | }, |
186 | }, | |
187 | { | |
188 | name => "npn-selected-sni-server-does-not-support-npn", | |
9f48bbac EK |
189 | server => { |
190 | extra => { | |
191 | "NPNProtocols" => "bar", | |
192 | "ServerNameCallback" => "IgnoreMismatch", | |
193 | }, | |
194 | }, | |
ce2cdac2 | 195 | server2 => { }, |
9f48bbac EK |
196 | client => { |
197 | extra => { | |
198 | "NPNProtocols" => "foo,bar", | |
199 | "ServerName" => "server2", | |
200 | }, | |
0f1e51ea | 201 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 202 | }, |
ce2cdac2 | 203 | test => { |
ce2cdac2 EK |
204 | "ExpectedServerName" => "server2", |
205 | "ExpectedNPNProtocol" => undef, | |
206 | }, | |
207 | }, | |
208 | { | |
209 | name => "alpn-preferred-over-npn", | |
9f48bbac EK |
210 | server => { |
211 | extra => { | |
212 | "ALPNProtocols" => "foo", | |
213 | "NPNProtocols" => "bar", | |
214 | }, | |
215 | }, | |
216 | client => { | |
217 | extra => { | |
218 | "ALPNProtocols" => "foo", | |
219 | "NPNProtocols" => "bar", | |
220 | }, | |
0f1e51ea | 221 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 222 | }, |
ce2cdac2 | 223 | test => { |
2ac6bdc0 EK |
224 | "ExpectedALPNProtocol" => "foo", |
225 | "ExpectedNPNProtocol" => undef, | |
ce2cdac2 EK |
226 | }, |
227 | }, | |
228 | { | |
229 | name => "sni-npn-preferred-over-alpn", | |
9f48bbac EK |
230 | server => { |
231 | extra => { | |
232 | "ServerNameCallback" => "IgnoreMismatch", | |
233 | "ALPNProtocols" => "foo", | |
234 | }, | |
235 | }, | |
236 | server2 => { | |
237 | extra => { | |
238 | "NPNProtocols" => "bar", | |
239 | }, | |
240 | }, | |
241 | client => { | |
242 | extra => { | |
243 | "ServerName" => "server2", | |
244 | "ALPNProtocols" => "foo", | |
245 | "NPNProtocols" => "bar", | |
246 | }, | |
0f1e51ea | 247 | "MaxProtocol" => "TLSv1.2" |
9f48bbac | 248 | }, |
ce2cdac2 | 249 | test => { |
2ac6bdc0 EK |
250 | "ExpectedALPNProtocol" => undef, |
251 | "ExpectedNPNProtocol" => "bar", | |
252 | "ExpectedServerName" => "server2", | |
253 | }, | |
254 | }, | |
255 | { | |
256 | name => "npn-simple-resumption", | |
257 | server => { | |
258 | extra => { | |
259 | "NPNProtocols" => "foo", | |
260 | }, | |
261 | }, | |
262 | client => { | |
263 | extra => { | |
264 | "NPNProtocols" => "foo", | |
265 | }, | |
0f1e51ea | 266 | "MaxProtocol" => "TLSv1.2" |
2ac6bdc0 EK |
267 | }, |
268 | test => { | |
269 | "HandshakeMode" => "Resume", | |
270 | "ResumptionExpected" => "Yes", | |
271 | "ExpectedNPNProtocol" => "foo", | |
272 | }, | |
273 | }, | |
274 | { | |
275 | name => "npn-server-switch-resumption", | |
276 | server => { | |
277 | extra => { | |
278 | "NPNProtocols" => "bar,foo", | |
279 | }, | |
280 | }, | |
281 | resume_server => { | |
282 | extra => { | |
283 | "NPNProtocols" => "baz,foo", | |
284 | }, | |
285 | }, | |
286 | client => { | |
287 | extra => { | |
288 | "NPNProtocols" => "foo,bar,baz", | |
289 | }, | |
0f1e51ea | 290 | "MaxProtocol" => "TLSv1.2" |
2ac6bdc0 EK |
291 | }, |
292 | test => { | |
293 | "HandshakeMode" => "Resume", | |
294 | "ResumptionExpected" => "Yes", | |
295 | "ExpectedNPNProtocol" => "baz", | |
296 | }, | |
297 | }, | |
298 | { | |
299 | name => "npn-client-switch-resumption", | |
300 | server => { | |
301 | extra => { | |
302 | "NPNProtocols" => "foo,bar,baz", | |
303 | }, | |
304 | }, | |
305 | client => { | |
306 | extra => { | |
307 | "NPNProtocols" => "foo,baz", | |
308 | }, | |
0f1e51ea | 309 | "MaxProtocol" => "TLSv1.2" |
2ac6bdc0 EK |
310 | }, |
311 | resume_client => { | |
312 | extra => { | |
313 | "NPNProtocols" => "bar,baz", | |
314 | }, | |
0f1e51ea | 315 | "MaxProtocol" => "TLSv1.2" |
2ac6bdc0 EK |
316 | }, |
317 | test => { | |
318 | "HandshakeMode" => "Resume", | |
319 | "ResumptionExpected" => "Yes", | |
320 | "ExpectedNPNProtocol" => "bar", | |
321 | }, | |
322 | }, | |
323 | { | |
324 | name => "npn-client-first-pref-on-mismatch-resumption", | |
325 | server => { | |
326 | extra => { | |
327 | "NPNProtocols" => "bar", | |
328 | }, | |
329 | }, | |
330 | resume_server => { | |
331 | extra => { | |
332 | "NPNProtocols" => "baz", | |
333 | }, | |
334 | }, | |
335 | client => { | |
336 | extra => { | |
337 | "NPNProtocols" => "foo,bar", | |
338 | }, | |
0f1e51ea | 339 | "MaxProtocol" => "TLSv1.2" |
2ac6bdc0 EK |
340 | }, |
341 | test => { | |
342 | "HandshakeMode" => "Resume", | |
343 | "ResumptionExpected" => "Yes", | |
344 | "ExpectedNPNProtocol" => "foo", | |
345 | }, | |
346 | }, | |
347 | { | |
348 | name => "npn-no-server-support-resumption", | |
349 | server => { | |
350 | extra => { | |
351 | "NPNProtocols" => "foo", | |
352 | }, | |
353 | }, | |
354 | resume_server => { }, | |
355 | client => { | |
356 | extra => { | |
357 | "NPNProtocols" => "foo", | |
358 | }, | |
0f1e51ea | 359 | "MaxProtocol" => "TLSv1.2" |
2ac6bdc0 EK |
360 | }, |
361 | test => { | |
362 | "HandshakeMode" => "Resume", | |
363 | "ResumptionExpected" => "Yes", | |
364 | "ExpectedNPNProtocol" => undef, | |
365 | }, | |
366 | }, | |
367 | { | |
368 | name => "npn-no-client-support-resumption", | |
369 | server => { | |
370 | extra => { | |
371 | "NPNProtocols" => "foo", | |
372 | }, | |
373 | }, | |
374 | client => { | |
375 | extra => { | |
376 | "NPNProtocols" => "foo", | |
377 | }, | |
0f1e51ea MC |
378 | "MaxProtocol" => "TLSv1.2" |
379 | }, | |
380 | resume_client => { | |
381 | "MaxProtocol" => "TLSv1.2" | |
2ac6bdc0 | 382 | }, |
2ac6bdc0 EK |
383 | test => { |
384 | "HandshakeMode" => "Resume", | |
385 | "ResumptionExpected" => "Yes", | |
386 | "ExpectedNPNProtocol" => undef, | |
387 | }, | |
388 | }, | |
389 | { | |
390 | name => "alpn-preferred-over-npn-resumption", | |
391 | server => { | |
392 | extra => { | |
393 | "NPNProtocols" => "bar", | |
394 | }, | |
395 | }, | |
396 | resume_server => { | |
397 | extra => { | |
398 | "ALPNProtocols" => "foo", | |
399 | "NPNProtocols" => "baz", | |
400 | }, | |
401 | }, | |
402 | client => { | |
403 | extra => { | |
404 | "ALPNProtocols" => "foo", | |
405 | "NPNProtocols" => "bar,baz", | |
406 | }, | |
0f1e51ea | 407 | "MaxProtocol" => "TLSv1.2" |
2ac6bdc0 EK |
408 | }, |
409 | test => { | |
410 | "HandshakeMode" => "Resume", | |
411 | "ResumptionExpected" => "Yes", | |
412 | "ExpectedALPNProtocol" => "foo", | |
413 | "ExpectedNPNProtocol" => undef, | |
414 | }, | |
415 | }, | |
416 | { | |
417 | name => "npn-used-if-alpn-not-supported-resumption", | |
418 | server => { | |
419 | extra => { | |
420 | "ALPNProtocols" => "foo", | |
421 | "NPNProtocols" => "bar", | |
422 | }, | |
423 | }, | |
424 | resume_server => { | |
425 | extra => { | |
426 | "NPNProtocols" => "baz", | |
427 | }, | |
428 | }, | |
429 | client => { | |
430 | extra => { | |
431 | "ALPNProtocols" => "foo", | |
432 | "NPNProtocols" => "bar,baz", | |
433 | }, | |
0f1e51ea | 434 | "MaxProtocol" => "TLSv1.2" |
2ac6bdc0 EK |
435 | }, |
436 | test => { | |
437 | "HandshakeMode" => "Resume", | |
438 | "ResumptionExpected" => "Yes", | |
439 | "ExpectedALPNProtocol" => undef, | |
440 | "ExpectedNPNProtocol" => "baz", | |
ce2cdac2 EK |
441 | }, |
442 | }, | |
443 | ); |