Skip to content

Commit 15c153e

Browse files
committed
* Add test for use_ssl + use_starttls combo
1 parent ccb28d8 commit 15c153e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap_mgmt.erl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ accept_content(ReqData0, Context) ->
8080
Reason = unicode_format(E),
8181
rabbit_mgmt_util:unprocessable_entity(Reason, ReqData1, Context)
8282
end;
83+
{error, tls_already_started} ->
84+
rabbit_mgmt_util:unprocessable_entity("TLS configuration error: "
85+
"cannot use StartTLS on an SSL connection "
86+
"(use_ssl and use_starttls cannot both be true)",
87+
ReqData1, Context);
8388
Error ->
8489
Reason = unicode_format(Error),
8590
rabbit_mgmt_util:unprocessable_entity(Reason, ReqData1, Context)

deps/rabbitmq_auth_backend_ldap/test/system_SUITE.erl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,27 @@ validate_ldap_configuration_via_api(Config) ->
502502
?assertEqual(<<"unprocessable_entity">>, maps:get(<<"error">>, LongPasswordJson)),
503503
?assertEqual(<<"invalid LDAP credentials: authentication failure">>,
504504
maps:get(<<"reason">>, LongPasswordJson)),
505+
506+
%% SSL/TLS Edge Cases
507+
%% Both use_ssl and use_starttls set to true - TLS configuration error
508+
{ok, {{_, 422, _}, _Headers5, BothTlsBody}} =
509+
rabbit_mgmt_test_util:req(Config, 0, put, "/ldap/validate/simple-bind",
510+
[rabbit_mgmt_test_util:auth_header("guest", "guest")],
511+
rabbit_mgmt_test_util:format_for_upload(#{
512+
'user_dn' => AliceUserDN,
513+
'password' => Password,
514+
'servers' => ["localhost"],
515+
'port' => LdapTlsPort,
516+
'use_ssl' => true,
517+
'use_starttls' => true,
518+
'ssl_options' => #{
519+
'cacertfile' => CaCertfile
520+
}
521+
})),
522+
BothTlsJson = rabbit_json:decode(BothTlsBody),
523+
?assertEqual(<<"unprocessable_entity">>, maps:get(<<"error">>, BothTlsJson)),
524+
?assertEqual(<<"TLS configuration error: cannot use StartTLS on an SSL connection (use_ssl and use_starttls cannot both be true)">>,
525+
maps:get(<<"reason">>, BothTlsJson)),
505526
http_put(Config, "/ldap/validate/simple-bind",
506527
#{
507528
'user_dn' => AliceUserDN,

0 commit comments

Comments
 (0)