@@ -1684,9 +1684,10 @@ close_with_timeout(Config) when is_list(Config) ->
16841684close_in_error_state () ->
16851685 [{doc ," Special case of closing socket in error state" }].
16861686close_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 ),
16881688 ServerOpts = [{cacertfile , " foo.pem" } | proplists :delete (cacertfile , ServerOpts0 )],
16891689 ClientOpts = ssl_test_lib :ssl_options (client_opts , Config ),
1690+
16901691 _ = spawn (? MODULE , run_error_server_close , [[self () | ServerOpts ]]),
16911692 receive
16921693 {_Pid , Port } ->
@@ -1703,7 +1704,7 @@ close_in_error_state(Config) when is_list(Config) ->
17031704call_in_error_state () ->
17041705 [{doc ," Special case of call error handling" }].
17051706call_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 ),
17071708 ClientOpts = ssl_test_lib :ssl_options (client_opts , Config ),
17081709 ServerOpts = [{cacertfile , " foo.pem" } | proplists :delete (cacertfile , ServerOpts0 )],
17091710 Pid = spawn (? MODULE , run_error_server , [[self () | ServerOpts ]]),
@@ -2187,27 +2188,44 @@ options_whitebox() ->
21872188customize_defaults (Opts , Role , Host ) ->
21882189 % % In many options test scenarios we do not care about verifcation options
21892190 % % 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 ,
21962214 case proplists :get_value (protocol , Opts , tls ) of
21972215 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 };
22002218 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 ),
22022220 case proplists :get_value (versions , Opts ) of
22032221 undefined ->
2204- {DOpts , ClientIgnorDef ++ [{versions , ['tlsv1.2' ,'tlsv1.3' ]}|Opts ]};
2222+ {DOpts , DefOpts ++ [{versions , ['tlsv1.2' ,'tlsv1.3' ]}|Opts ]};
22052223 _ ->
2206- {DOpts , ClientIgnorDef ++ Opts }
2224+ {DOpts , DefOpts ++ Opts }
22072225 end ;
22082226 _ ->
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 }
22112229 end .
22122230
22132231-define (OK (EXP , Opts , Role ), ? OK (EXP ,Opts , Role , [])).
@@ -2279,6 +2297,41 @@ customize_defaults(Opts, Role, Host) ->
22792297 end
22802298 end ()).
22812299
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+
22822335options_whitebox (Config ) when is_list (Config ) ->
22832336 Cert = proplists :get_value (cert , ssl_test_lib :ssl_options (server_rsa_der_opts , Config )),
22842337 true = is_binary (Cert ),
@@ -2520,6 +2573,7 @@ options_cert(Config) -> %% cert[file] cert_keys keys password
25202573 ? ERR ({cert , #{}}, [{cert , #{}}], client ),
25212574 ? ERR ({certfile , cert }, [{certfile , cert }], client ),
25222575 ? ERR ({certs_keys , #{}}, [{certs_keys , #{}}], client ),
2576+ ? ERR_UPD ({certs_keys , no_cert_or_key_given }, [{certs_keys , []}], server ),
25232577 ? ERR ({keyfile , #{}}, [{keyfile , #{}}], client ),
25242578 ? ERR ({key , <<>>}, [{key , <<>>}], client ),
25252579 ? ERR ({password , _ }, [{password , fun (Arg ) -> Arg end }], client ),
@@ -2548,7 +2602,11 @@ options_ciphers(_Config) ->
25482602 ? OK (#{ciphers := [_ |_ ]}, [{ciphers , " RC4-SHA:RC4-MD5" }], client ),
25492603 ? OK (#{ciphers := [_ |_ ]}, [{ciphers , [" RC4-SHA" , " RC4-MD5" ]}], client ),
25502604
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 ),
25522610 ok .
25532611
25542612options_client_renegotiation (_Config ) ->
0 commit comments