08-npn.cnf.in 12 KB

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