39
39
end_per_testcase /2 ]).
40
40
41
41
% % Testcases
42
- -export ([no_sni_header /1 ,
42
+ -export ([no_sni_ext /1 ,
43
43
sni_match /1 ,
44
44
sni_no_match /1 ,
45
- no_sni_header_fun /1 ,
45
+ no_sni_ext_fun /1 ,
46
46
sni_match_fun /1 ,
47
47
sni_no_match_fun /1 ,
48
+ sni_fail_fun /1 ,
49
+ sni_crash_fun /1 ,
48
50
dns_name /1 ,
49
51
ip_fallback /1 ,
50
52
no_ip_fallback /1 ,
@@ -88,12 +90,14 @@ groups() ->
88
90
].
89
91
90
92
sni_tests () ->
91
- [no_sni_header ,
93
+ [no_sni_ext ,
92
94
sni_match ,
93
95
sni_no_match ,
94
- no_sni_header_fun ,
96
+ no_sni_ext_fun ,
95
97
sni_match_fun ,
96
98
sni_no_match_fun ,
99
+ sni_fail_fun ,
100
+ sni_crash_fun ,
97
101
dns_name ,
98
102
ip_fallback ,
99
103
no_ip_fallback ,
@@ -148,14 +152,14 @@ end_per_testcase(_TestCase, Config) ->
148
152
% %--------------------------------------------------------------------
149
153
% % Test Cases --------------------------------------------------------
150
154
% %--------------------------------------------------------------------
151
- no_sni_header (Config ) ->
155
+ no_sni_ext (Config ) ->
152
156
{ClientNode , ServerNode , HostName } = ssl_test_lib :run_where (Config ),
153
157
ServerOptions = ssl_test_lib :ssl_options (proplists :get_value (sni_server_opts , Config ), Config ),
154
158
ClientOptions = ssl_test_lib :ssl_options ([{server_name_indication , disable } |
155
159
proplists :get_value (client_local_opts , Config )], Config ),
156
160
basic_sni_test (ServerNode , ServerOptions , ClientNode , ClientOptions , HostName , undefined ).
157
161
158
- no_sni_header_fun (Config ) ->
162
+ no_sni_ext_fun (Config ) ->
159
163
{ClientNode , ServerNode , HostName } = ssl_test_lib :run_where (Config ),
160
164
[{sni_hosts , ServerSNIConf }| DefaultConf ] = proplists :get_value (sni_server_opts , Config ),
161
165
SNIFun = fun (Domain ) -> proplists :get_value (Domain , ServerSNIConf , []) end ,
@@ -174,7 +178,7 @@ sni_match(Config) ->
174
178
sni_match_fun (Config ) ->
175
179
{ClientNode , ServerNode , HostName } = ssl_test_lib :run_where (Config ),
176
180
[{sni_hosts , ServerSNIConf }| DefaultConf ] = proplists :get_value (sni_server_opts , Config ),
177
- SNIFun = fun (Domain ) -> proplists :get_value (Domain , ServerSNIConf , undefined ) end ,
181
+ SNIFun = fun (Domain ) -> proplists :get_value (Domain , ServerSNIConf , unrecognized ) end ,
178
182
ServerOptions = ssl_test_lib :ssl_options (DefaultConf , Config ) ++ [{sni_fun , SNIFun }],
179
183
ClientOptions = ssl_test_lib :ssl_options ([{server_name_indication , HostName } |
180
184
proplists :get_value (client_opts , Config )], Config ),
@@ -186,15 +190,38 @@ sni_no_match(Config) ->
186
190
ClientOptions = ssl_test_lib :ssl_options ([{server_name_indication , HostName } |
187
191
proplists :get_value (client_opts , Config )], Config ),
188
192
ServerOptions = ssl_test_lib :ssl_options (DefaultConf , Config ),
189
- basic_sni_alert_test (ServerNode , ServerOptions , ClientNode , ClientOptions , HostName ).
193
+ basic_sni_alert_test (ServerNode , ServerOptions , ClientNode , ClientOptions , HostName , handshake_failure ).
190
194
191
195
sni_no_match_fun (Config ) ->
192
196
{ClientNode , ServerNode , HostName } = ssl_test_lib :run_where (Config ),
193
- [{sni_hosts , _ }| DefaultConf ] = proplists :get_value (sni_server_opts , Config ),
194
- ServerOptions = ssl_test_lib :ssl_options (DefaultConf , Config ),
195
- ClientOptions = ssl_test_lib :ssl_options ([{server_name_indication , HostName } |
197
+ [{sni_hosts , ServerSNIConf }| DefaultConf ] = proplists :get_value (sni_server_opts , Config ),
198
+ SNIFun = fun (Domain ) -> proplists :get_value (Domain , ServerSNIConf , unrecognized ) end ,
199
+ ServerOptions = ssl_test_lib :ssl_options (DefaultConf , Config ) ++ [{sni_fun , SNIFun }],
200
+ ClientOptions = ssl_test_lib :ssl_options ([{server_name_indication , " localhost" } |
196
201
proplists :get_value (client_local_opts , Config )], Config ),
197
- basic_sni_alert_test (ServerNode , ServerOptions , ClientNode , ClientOptions , HostName ).
202
+ basic_sni_alert_test (ServerNode , ServerOptions , ClientNode , ClientOptions , HostName , unrecognized_name ).
203
+
204
+ sni_fail_fun (Config ) ->
205
+ {ClientNode , ServerNode , HostName } = ssl_test_lib :run_where (Config ),
206
+ [_ | DefaultConf ] = proplists :get_value (sni_server_opts , Config ),
207
+ ServerOptions = ssl_test_lib :ssl_options (DefaultConf , Config ) ,
208
+ ClientOptions = ssl_test_lib :ssl_options ([{server_name_indication , HostName } |
209
+ proplists :get_value (client_opts , Config )], Config ),
210
+ basic_sni_alert_test (ServerNode , ServerOptions ++ [{sni_fun , fun (_Domain ) -> [{versions , ['tlsv1.5' ]}] end }],
211
+ ClientNode , ClientOptions , HostName , handshake_failure ),
212
+ basic_sni_alert_test (ServerNode , ServerOptions ++ [{sni_fun , fun (_Domain ) -> [{verify , foobar }] end }],
213
+ ClientNode , ClientOptions , HostName , handshake_failure ).
214
+
215
+ sni_crash_fun (Config ) ->
216
+ {ClientNode , ServerNode , HostName } = ssl_test_lib :run_where (Config ),
217
+ [_ | DefaultConf ] = proplists :get_value (sni_server_opts , Config ),
218
+ SNIFun = fun (Domain ) -> Domain = nomatch end ,
219
+ ServerOptions = ssl_test_lib :ssl_options (DefaultConf , Config ) ++ [{sni_fun , SNIFun }],
220
+ ClientOptions = ssl_test_lib :ssl_options ([{server_name_indication , HostName } |
221
+ proplists :get_value (client_opts , Config )], Config ),
222
+ basic_sni_alert_test (ServerNode , ServerOptions , ClientNode , ClientOptions , HostName , handshake_failure ).
223
+
224
+
198
225
199
226
dns_name (Config ) ->
200
227
Hostname = " OTP.test.server" ,
@@ -215,12 +242,12 @@ dns_name(Config) ->
215
242
Version = ssl_test_lib :n_version (proplists :get_value (version , Config )),
216
243
ServerConf = ssl_test_lib :sig_algs (rsa , Version ) ++ ServerOpts0 ,
217
244
ClientConf = ssl_test_lib :sig_algs (rsa , Version ) ++ ClientOpts0 ,
218
- unsuccessfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], undefined , Config ),
219
- successfull_connect (ServerConf , [{verify , verify_peer },
245
+ unsuccessful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], undefined , Config , handshake_failure ),
246
+ successful_connect (ServerConf , [{verify , verify_peer },
220
247
{server_name_indication , Hostname } | ClientConf ], undefined , Config ),
221
- unsuccessfull_connect (ServerConf , [{verify , verify_peer }, {server_name_indication , " foo" } | ClientConf ],
222
- undefined , Config ),
223
- successfull_connect (ServerConf , [{verify , verify_peer }, {server_name_indication , disable } | ClientConf ],
248
+ unsuccessful_connect (ServerConf , [{verify , verify_peer }, {server_name_indication , " foo" } | ClientConf ],
249
+ undefined , Config , handshake_failure ),
250
+ successful_connect (ServerConf , [{verify , verify_peer }, {server_name_indication , disable } | ClientConf ],
224
251
undefined , Config ).
225
252
226
253
ip_fallback (Config ) ->
@@ -246,10 +273,10 @@ ip_fallback(Config) ->
246
273
Version = ssl_test_lib :n_version (proplists :get_value (version , Config )),
247
274
ServerConf = ssl_test_lib :sig_algs (rsa , Version ) ++ ServerOpts0 ,
248
275
ClientConf = ssl_test_lib :sig_algs (rsa , Version ) ++ ClientOpts0 ,
249
- successfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], Hostname , Config ),
250
- successfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], IP , Config ),
251
- successfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], IPStr , Config ),
252
- successfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], list_to_atom (Hostname ), Config ).
276
+ successful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], Hostname , Config ),
277
+ successful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], IP , Config ),
278
+ successful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], IPStr , Config ),
279
+ successful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], list_to_atom (Hostname ), Config ).
253
280
254
281
no_ip_fallback (Config ) ->
255
282
Hostname = net_adm :localhost (),
@@ -274,9 +301,9 @@ no_ip_fallback(Config) ->
274
301
Version = ssl_test_lib :n_version (proplists :get_value (version , Config )),
275
302
ServerConf = ssl_test_lib :sig_algs (rsa , Version ) ++ ServerOpts0 ,
276
303
ClientConf = ssl_test_lib :sig_algs (rsa , Version ) ++ ClientOpts0 ,
277
- successfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], Hostname , Config ),
278
- unsuccessfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], IP , Config ),
279
- unsuccessfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], IPStr , Config ).
304
+ successful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], Hostname , Config ),
305
+ unsuccessful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], IP , Config , handshake_failure ),
306
+ unsuccessful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], IPStr , Config , handshake_failure ).
280
307
281
308
dns_name_reuse (Config ) ->
282
309
SNIHostname = " OTP.test.server" ,
@@ -302,7 +329,7 @@ dns_name_reuse(Config) ->
302
329
303
330
{ClientNode , ServerNode , Hostname } = ssl_test_lib :run_where (Config ),
304
331
305
- unsuccessfull_connect (ServerConf , [{verify , verify_peer } | ClientConf ], undefined , Config ),
332
+ unsuccessful_connect (ServerConf , [{verify , verify_peer } | ClientConf ], undefined , Config , handshake_failure ),
306
333
307
334
Server =
308
335
ssl_test_lib :start_server ([{node , ServerNode }, {port , 0 },
@@ -475,19 +502,19 @@ basic_sni_test(ServerNode, ServerOptions, ClientNode, ClientOptions, HostName, E
475
502
ssl_test_lib :close (Server ),
476
503
ssl_test_lib :close (Client ).
477
504
478
- basic_sni_alert_test (ServerNode , ServerOptions , ClientNode , ClientOptions , HostName ) ->
505
+ basic_sni_alert_test (ServerNode , ServerOptions , ClientNode , ClientOptions , HostName , Alert ) ->
479
506
Server = ssl_test_lib :start_server ([{node , ServerNode }, {port , 0 },
480
507
{from , self ()}, {mfa , {ssl_test_lib , no_result , []}},
481
508
{options , ServerOptions }]),
482
509
Port = ssl_test_lib :inet_port (Server ),
483
510
Client = ssl_test_lib :start_client_error ([{node , ClientNode }, {port , Port },
484
511
{host , HostName }, {from , self ()},
485
512
{options , [{verify , verify_peer } | ClientOptions ]}]),
486
- ssl_test_lib :check_client_alert (Client , handshake_failure ),
513
+ ssl_test_lib :check_client_alert (Client , Alert ),
487
514
ssl_test_lib :close (Server ),
488
515
ssl_test_lib :close (Client ).
489
516
490
- successfull_connect (ServerOptions , ClientOptions , Hostname0 , Config ) ->
517
+ successful_connect (ServerOptions , ClientOptions , Hostname0 , Config ) ->
491
518
{ClientNode , ServerNode , Hostname1 } = ssl_test_lib :run_where (Config ),
492
519
Hostname = host_name (Hostname0 , Hostname1 ),
493
520
Server = ssl_test_lib :start_server ([{node , ServerNode }, {port , 0 },
@@ -502,7 +529,7 @@ successfull_connect(ServerOptions, ClientOptions, Hostname0, Config) ->
502
529
ssl_test_lib :close (Server ),
503
530
ssl_test_lib :close (Client ).
504
531
505
- unsuccessfull_connect (ServerOptions , ClientOptions , Hostname0 , Config ) ->
532
+ unsuccessful_connect (ServerOptions , ClientOptions , Hostname0 , Config , Alert ) ->
506
533
{ClientNode , ServerNode , Hostname1 } = ssl_test_lib :run_where (Config ),
507
534
Hostname = host_name (Hostname0 , Hostname1 ),
508
535
Server = ssl_test_lib :start_server_error ([{node , ServerNode }, {port , 0 },
@@ -514,7 +541,7 @@ unsuccessfull_connect(ServerOptions, ClientOptions, Hostname0, Config) ->
514
541
{from , self ()},
515
542
{options , ClientOptions }]),
516
543
517
- ssl_test_lib :check_server_alert (Server , Client , handshake_failure ).
544
+ ssl_test_lib :check_server_alert (Server , Client , Alert ).
518
545
519
546
host_name (undefined , Hostname ) ->
520
547
Hostname ;
0 commit comments