@@ -1684,9 +1684,10 @@ close_with_timeout(Config) when is_list(Config) ->
1684
1684
close_in_error_state () ->
1685
1685
[{doc ," Special case of closing socket in error state" }].
1686
1686
close_in_error_state (Config ) when is_list (Config ) ->
1687
- ServerOpts0 = ssl_test_lib :ssl_options (server_opts , Config ),
1687
+ ServerOpts0 = ssl_test_lib :ssl_options (server_rsa_opts , Config ),
1688
1688
ServerOpts = [{cacertfile , " foo.pem" } | proplists :delete (cacertfile , ServerOpts0 )],
1689
1689
ClientOpts = ssl_test_lib :ssl_options (client_opts , Config ),
1690
+
1690
1691
_ = spawn (? MODULE , run_error_server_close , [[self () | ServerOpts ]]),
1691
1692
receive
1692
1693
{_Pid , Port } ->
@@ -1703,7 +1704,7 @@ close_in_error_state(Config) when is_list(Config) ->
1703
1704
call_in_error_state () ->
1704
1705
[{doc ," Special case of call error handling" }].
1705
1706
call_in_error_state (Config ) when is_list (Config ) ->
1706
- ServerOpts0 = ssl_test_lib :ssl_options (server_opts , Config ),
1707
+ ServerOpts0 = ssl_test_lib :ssl_options (server_rsa_opts , Config ),
1707
1708
ClientOpts = ssl_test_lib :ssl_options (client_opts , Config ),
1708
1709
ServerOpts = [{cacertfile , " foo.pem" } | proplists :delete (cacertfile , ServerOpts0 )],
1709
1710
Pid = spawn (? MODULE , run_error_server , [[self () | ServerOpts ]]),
@@ -2187,27 +2188,44 @@ options_whitebox() ->
2187
2188
customize_defaults (Opts , Role , Host ) ->
2188
2189
% % In many options test scenarios we do not care about verifcation options
2189
2190
% % but the client now requiers verification options by default.
2190
- ClientIgnorDef = case proplists :get_value (verify , Opts , undefined ) of
2191
- undefined when Role == client ->
2192
- [{verify , verify_none }];
2193
- _ ->
2194
- []
2195
- end ,
2191
+ DefOpts = case Role of
2192
+ client ->
2193
+ case proplists :get_value (verify , Opts , undefined ) of
2194
+ undefined -> [{verify , verify_none }];
2195
+ _ -> []
2196
+ end ;
2197
+ server ->
2198
+ Ciphers = proplists :get_value (ciphers , Opts , undefined ),
2199
+ Cert = proplists :get_value (cert , Opts , undefined ),
2200
+ Key = proplists :get_value (key , Opts , undefined ),
2201
+ CertsKeys = proplists :get_value (certs_keys , Opts , undefined ),
2202
+ NoCertOrKeys = Cert == undefined orelse Key == undefined andalso
2203
+ CertsKeys == undefined ,
2204
+ if Ciphers == undefined andalso NoCertOrKeys ->
2205
+ [{certs_keys , [#{cert => <<>>, key => {rsa , <<>>}}]}];
2206
+ true ->
2207
+ []
2208
+ end
2209
+ end ,
2210
+ NoVerify = case Role of
2211
+ client -> [{verify , verify_none }|DefOpts ];
2212
+ server -> DefOpts
2213
+ end ,
2196
2214
case proplists :get_value (protocol , Opts , tls ) of
2197
2215
dtls ->
2198
- {ok , # config {ssl = DOpts }} = ssl :handle_options ([{verify , verify_none }, { protocol , dtls }], Role , Host ),
2199
- {DOpts , ClientIgnorDef ++ Opts };
2216
+ {ok , # config {ssl = DOpts }} = ssl :handle_options ([{protocol , dtls }| NoVerify ], Role , Host ),
2217
+ {DOpts , DefOpts ++ Opts };
2200
2218
tls ->
2201
- {ok , # config {ssl = DOpts }} = ssl :handle_options ([{ verify , verify_none }] , Role , Host ),
2219
+ {ok , # config {ssl = DOpts }} = ssl :handle_options (NoVerify , Role , Host ),
2202
2220
case proplists :get_value (versions , Opts ) of
2203
2221
undefined ->
2204
- {DOpts , ClientIgnorDef ++ [{versions , ['tlsv1.2' ,'tlsv1.3' ]}|Opts ]};
2222
+ {DOpts , DefOpts ++ [{versions , ['tlsv1.2' ,'tlsv1.3' ]}|Opts ]};
2205
2223
_ ->
2206
- {DOpts , ClientIgnorDef ++ Opts }
2224
+ {DOpts , DefOpts ++ Opts }
2207
2225
end ;
2208
2226
_ ->
2209
- {ok , # config {ssl = DOpts }} = ssl :handle_options (ClientIgnorDef , Role , Host ),
2210
- {DOpts , ClientIgnorDef ++ Opts }
2227
+ {ok , # config {ssl = DOpts }} = ssl :handle_options (NoVerify , Role , Host ),
2228
+ {DOpts , DefOpts ++ Opts }
2211
2229
end .
2212
2230
2213
2231
-define (OK (EXP , Opts , Role ), ? OK (EXP ,Opts , Role , [])).
@@ -2279,6 +2297,41 @@ customize_defaults(Opts, Role, Host) ->
2279
2297
end
2280
2298
end ()).
2281
2299
2300
+ -define (ERR_UPD (EXP , Opts , Role ),
2301
+ fun () ->
2302
+ Host = " dummy.host.org" ,
2303
+ {__DefOpts , __Opts } = customize_defaults (Opts , Role , Host ),
2304
+ try ssl :handle_options (__Opts , Role , Host ) of
2305
+ {ok , # config {}} ->
2306
+ ok ;
2307
+ Other ->
2308
+ ? CT_PAL (" ssl:handle_options(~0p ,~0p ,~0p )." ,[__Opts ,Role ,Host ]),
2309
+ error ({unexpected , Other })
2310
+ catch
2311
+ throw :{error ,{options ,{insufficient_crypto_support ,{'tlsv1.3' ,_ }}}} -> ignored ;
2312
+ C :Other :ST ->
2313
+ ? CT_PAL (" ssl:handle_options(~0p ,~0p ,~0p )." ,[__Opts ,Role ,Host ]),
2314
+ error ({unexpected , C , Other ,ST })
2315
+ end ,
2316
+ try ssl :update_options (__Opts , Role , __DefOpts ) of
2317
+ Other2 ->
2318
+ ? CT_PAL (" {ok,Cfg} = ssl:handle_options([],~p ,~p ),"
2319
+ " ssl:update_options(~p ,~p , element(2,Cfg))." ,
2320
+ [Role ,Host ,__Opts ,Role ]),
2321
+ error ({unexpected , Other2 })
2322
+ catch
2323
+ throw :{error ,{options ,{insufficient_crypto_support ,{'tlsv1.3' ,_ }}}} -> ignored ;
2324
+ throw :{error , {options , EXP }} -> ok ;
2325
+ throw :{error , EXP } -> ok ;
2326
+ C2 :Other2 :ST2 ->
2327
+ ? CT_PAL (" {ok,Cfg} = ssl:handle_options([],~p ,~p ),"
2328
+ " ssl:update_options(~p ,~p , element(2,Cfg))." ,
2329
+ [Role ,Host ,__Opts ,Role ]),
2330
+ error ({unexpected , C2 , Other2 ,ST2 })
2331
+ end
2332
+ end ()).
2333
+
2334
+
2282
2335
options_whitebox (Config ) when is_list (Config ) ->
2283
2336
Cert = proplists :get_value (cert , ssl_test_lib :ssl_options (server_rsa_der_opts , Config )),
2284
2337
true = is_binary (Cert ),
@@ -2520,6 +2573,7 @@ options_cert(Config) -> %% cert[file] cert_keys keys password
2520
2573
? ERR ({cert , #{}}, [{cert , #{}}], client ),
2521
2574
? ERR ({certfile , cert }, [{certfile , cert }], client ),
2522
2575
? ERR ({certs_keys , #{}}, [{certs_keys , #{}}], client ),
2576
+ ? ERR_UPD ({certs_keys , no_cert_or_key_given }, [{certs_keys , []}], server ),
2523
2577
? ERR ({keyfile , #{}}, [{keyfile , #{}}], client ),
2524
2578
? ERR ({key , <<>>}, [{key , <<>>}], client ),
2525
2579
? ERR ({password , _ }, [{password , fun (Arg ) -> Arg end }], client ),
@@ -2548,7 +2602,11 @@ options_ciphers(_Config) ->
2548
2602
? OK (#{ciphers := [_ |_ ]}, [{ciphers , " RC4-SHA:RC4-MD5" }], client ),
2549
2603
? OK (#{ciphers := [_ |_ ]}, [{ciphers , [" RC4-SHA" , " RC4-MD5" ]}], client ),
2550
2604
2551
- % % FIXME extend this
2605
+ ? OK (#{ciphers := [_ |_ ]}, [{ciphers , [" TLS_DH_anon_WITH_AES_256_CBC_SHA256" ]}], server ),
2606
+ % % Errors
2607
+ ? ERR ({ciphers , _ }, [{ciphers , " foobar:RC4-MD5" }], client ),
2608
+ ? ERR ({ciphers , _ }, [{ciphers , [" RC4-SHA:RC4-MD5" , " RC4-SHA:RC4-MD5" ]}], client ),
2609
+ ? ERR_UPD ({certs_keys , no_cert_or_key_given }, [{ciphers , " RC4-SHA:RC4-MD5" }], server ),
2552
2610
ok .
2553
2611
2554
2612
options_client_renegotiation (_Config ) ->
0 commit comments