Skip to content

Commit e8cf69d

Browse files
committed
* Add validation tests for server_name_indication
1 parent 5dee48d commit e8cf69d

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap_mgmt.erl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ tls_options(BodyMap) when is_map_key(ssl_options, BodyMap) ->
190190
disable ->
191191
TlsOpts3;
192192
SniValue ->
193-
SniStr = unicode:characters_to_list(SniValue),
194-
[{server_name_indication, SniStr} | TlsOpts3]
193+
try
194+
SniStr = unicode:characters_to_list(SniValue),
195+
[{server_name_indication, SniStr} | TlsOpts3]
196+
catch
197+
error:badarg ->
198+
throw({bad_request, "invalid server_name_indication: expected string"});
199+
error:_ ->
200+
throw({bad_request, "invalid server_name_indication: expected string"})
201+
end
195202
end,
196203
TlsOpts5 = case maps:get(<<"depth">>, SslOptionsMap, undefined) of
197204
undefined ->

deps/rabbitmq_auth_backend_ldap/test/system_SUITE.erl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,34 @@ validate_ldap_configuration_via_api(Config) ->
602602
'cacertfile' => CaCertfile
603603
}
604604
}, ?BAD_REQUEST),
605+
606+
%% Invalid server_name_indication - integer instead of string
607+
http_put(Config, "/ldap/validate/simple-bind",
608+
#{
609+
'user_dn' => AliceUserDN,
610+
'password' => Password,
611+
'servers' => ["localhost"],
612+
'port' => LdapTlsPort,
613+
'use_ssl' => true,
614+
'ssl_options' => #{
615+
'server_name_indication' => 123,
616+
'cacertfile' => CaCertfile
617+
}
618+
}, ?BAD_REQUEST),
619+
620+
%% Invalid server_name_indication - boolean instead of string
621+
http_put(Config, "/ldap/validate/simple-bind",
622+
#{
623+
'user_dn' => AliceUserDN,
624+
'password' => Password,
625+
'servers' => ["localhost"],
626+
'port' => LdapTlsPort,
627+
'use_ssl' => true,
628+
'ssl_options' => #{
629+
'server_name_indication' => true,
630+
'cacertfile' => CaCertfile
631+
}
632+
}, ?BAD_REQUEST),
605633
http_put(Config, "/ldap/validate/simple-bind",
606634
#{
607635
'user_dn' => AliceUserDN,

0 commit comments

Comments
 (0)