@@ -280,9 +280,11 @@ lookup_oauth_provider_from_keyconfig() ->
280280 ssl_options = extract_ssl_options_as_list (Map )
281281 }.
282282
283+
284+
283285-spec extract_ssl_options_as_list (#{atom () => any ()}) -> proplists :proplist ().
284286extract_ssl_options_as_list (Map ) ->
285- {Verify , CaCerts , CaCertFile } = case maps : get ( peer_verification , Map , verify_peer ) of
287+ {Verify , CaCerts , CaCertFile } = case get_verify_or_peer_verification ( Map , verify_peer ) of
286288 verify_peer ->
287289 case maps :get (cacertfile , Map , undefined ) of
288290 undefined ->
@@ -323,6 +325,20 @@ extract_ssl_options_as_list(Map) ->
323325 []
324326 end .
325327
328+ % Replace peer_verification with verify to make it more consistent with other
329+ % ssl_options in RabbitMQ and Erlang's ssl options
330+ % Eventually, peer_verification will be removed. For now, both are allowed
331+ -spec get_verify_or_peer_verification (#{atom () => any ()}, any ()) -> proplists :proplist ().
332+ get_verify_or_peer_verification (Ssl_options , Default ) ->
333+ case maps :get (verify , Ssl_options , undefined ) of
334+ undefined ->
335+ case maps :get (peer_verification , Ssl_options , undefined ) of
336+ undefined -> Default ;
337+ PeerVerification -> PeerVerification
338+ end ;
339+ Verify -> Verify
340+ end .
341+
326342lookup_oauth_provider_config (OAuth2ProviderId ) ->
327343 case application :get_env (rabbitmq_auth_backend_oauth2 , oauth_providers ) of
328344 undefined -> {error , oauth_providers_not_found };
@@ -427,33 +443,10 @@ map_to_oauth_provider(PropList) when is_list(PropList) ->
427443 token_endpoint = proplists :get_value (token_endpoint , PropList ),
428444 authorization_endpoint = proplists :get_value (authorization_endpoint , PropList , undefined ),
429445 jwks_uri = proplists :get_value (jwks_uri , PropList , undefined ),
430- ssl_options = map_ssl_options (proplists :get_value (https , PropList , undefined ))
446+ ssl_options = extract_ssl_options_as_list (maps :from_list (
447+ proplists :get_value (https , PropList , [])))
431448 }.
432449
433- map_ssl_options (undefined ) ->
434- [{verify , verify_none },
435- {depth , 10 },
436- {fail_if_no_peer_cert , false },
437- {crl_check , false },
438- {crl_cache , {ssl_crl_cache , {internal , [{http , 10000 }]}}}];
439- map_ssl_options (Ssl_options ) ->
440- Ssl_options1 = [{verify , proplists :get_value (verify , Ssl_options , verify_none )},
441- {depth , proplists :get_value (depth , Ssl_options , 10 )},
442- {fail_if_no_peer_cert , proplists :get_value (fail_if_no_peer_cert , Ssl_options , false )},
443- {crl_check , proplists :get_value (crl_check , Ssl_options , false )},
444- {crl_cache , {ssl_crl_cache , {internal , [{http , 10000 }]}}} | cacertfile (Ssl_options )],
445- case proplists :get_value (hostname_verification , Ssl_options , none ) of
446- wildcard ->
447- [{customize_hostname_check , [{match_fun , public_key :pkix_verify_hostname_match_fun (https )}]} | Ssl_options1 ];
448- none ->
449- Ssl_options1
450- end .
451-
452- cacertfile (Ssl_options ) ->
453- case proplists :get_value (cacertfile , Ssl_options ) of
454- undefined -> [];
455- CaCertFile -> [{cacertfile , CaCertFile }]
456- end .
457450
458451enrich_oauth_provider ({ok , OAuthProvider }, TLSOptions ) ->
459452 {ok , OAuthProvider # oauth_provider {ssl_options = TLSOptions }};
0 commit comments