Skip to content

Commit d6bad82

Browse files
Merge pull request #14937 from amazon-mq/lukebakken/ssl-defaults
Always set and fix up TLS options in LDAP plugin
2 parents 1b56c4c + 0f3e5b4 commit d6bad82

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

deps/rabbit_common/src/rabbit_ssl_options.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ wrap_password_opt(Opts0) ->
3939
end.
4040

4141
-spec fix(rabbit_types:infos()) -> rabbit_types:infos().
42-
4342
fix(Config) ->
4443
fix_verify_fun(
4544
fix_ssl_protocol_versions(

deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap.erl

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -753,29 +753,32 @@ eldap_open(Servers, Opts) ->
753753
Error
754754
end.
755755

756+
%% We must make sure not to add SSL options unless:
757+
%% a) we have at least R16A
758+
%% b) we have SSL turned on (or it breaks StartTLS...)
756759
ssl_conf() ->
757-
%% We must make sure not to add SSL options unless a) we have at least R16A
758-
%% b) we have SSL turned on (or it breaks StartTLS...)
759-
case env(use_ssl, false) of
760-
false -> [{ssl, false}];
761-
true -> %% Only the unfixed version can be []
762-
case env(ssl_options) of
763-
[] -> [{ssl, true}];
764-
undefined -> [{ssl, true}];
765-
_ -> [{ssl, true}, {sslopts, ssl_options()}]
766-
end
767-
end.
760+
ssl_conf(env(use_ssl, false)).
761+
762+
ssl_conf(true) ->
763+
[{ssl, true}, {sslopts, ssl_options()}];
764+
ssl_conf(false) ->
765+
[{ssl, false}].
768766

769767
ssl_options() ->
770-
Opts0 = rabbit_ssl_options:fix_client(env(ssl_options)),
768+
ssl_options(env(ssl_options)).
769+
770+
ssl_options(undefined) ->
771+
ssl_options([{verify, verify_peer}]);
772+
ssl_options(Opts0) ->
773+
Opts1 = rabbit_ssl_options:fix_client(Opts0),
771774
case env(ssl_hostname_verification, undefined) of
772775
wildcard ->
773776
?LOG_DEBUG("Enabling wildcard-aware hostname verification for LDAP client connections"),
774777
%% Needed for non-HTTPS connections that connect to servers that use wildcard certificates.
775778
%% See https://erlang.org/doc/man/public_key.html#pkix_verify_hostname_match_fun-1.
776-
[{customize_hostname_check, [{match_fun, public_key:pkix_verify_hostname_match_fun(https)}]} | Opts0];
779+
[{customize_hostname_check, [{match_fun, public_key:pkix_verify_hostname_match_fun(https)}]} | Opts1];
777780
_ ->
778-
Opts0
781+
Opts1
779782
end.
780783

781784
at_least(Ver) ->
@@ -797,7 +800,7 @@ get_expected_env_str(Key, Default) ->
797800

798801
env(Key) ->
799802
case application:get_env(rabbitmq_auth_backend_ldap, Key) of
800-
{ok, V} -> V;
803+
{ok, V} -> V;
801804
undefined -> undefined
802805
end.
803806

0 commit comments

Comments
 (0)