Skip to content

Commit f1e2ac0

Browse files
Fix SAN type and bug
The bug is that when using ssl, it does not propagate credentials like vhost or client_id
1 parent b479e46 commit f1e2ac0

File tree

3 files changed

+10
-27
lines changed

3 files changed

+10
-27
lines changed

deps/rabbitmq_ct_helpers/tools/tls-certs/openssl.cnf.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ DNS.1 = @HOSTNAME@
6262
DNS.2 = localhost
6363

6464
[ client_alt_names ]
65-
CLIENT_ID.1 = rabbit_client_id
65+
DNS.1 = rabbit_client_id

deps/rabbitmq_mqtt/src/rabbit_mqtt_processor.erl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,14 @@ process_connect(
179179
ClientId1 ?= extract_preferred_client_id(ClientId0, Socket),
180180
{ok, ClientId} ?= ensure_client_id(ClientId1, CleanStart, ProtoVer),
181181
{ok, {Username1, Password}} ?= check_credentials(Username0, Password0, SslLoginName, PeerIp),
182-
?LOG_DEBUG("ClientId ~p ", [ClientId]),
183-
?LOG_DEBUG("Username1: ~p Password : ~p", [Username1, Password]),
184-
182+
185183
{VHostPickedUsing, {VHost, Username2}} = get_vhost(Username1, SslLoginName, Port),
186184
?LOG_DEBUG("MQTT connection ~s picked vhost using ~s", [ConnName0, VHostPickedUsing]),
187185
ok ?= check_vhost_exists(VHost, Username2, PeerIp),
188186
ok ?= check_vhost_alive(VHost),
189187
ok ?= check_vhost_connection_limit(VHost),
190188
{ok, User = #user{username = Username}} ?= check_user_login(VHost, Username2, Password,
191189
ClientId, PeerIp, ConnName0),
192-
?LOG_DEBUG("User: ~p ", [User]),
193190

194191
ok ?= check_user_connection_limit(Username),
195192
{ok, AuthzCtx} ?= check_vhost_access(VHost, User, ClientId, PeerIp),
@@ -1038,15 +1035,11 @@ check_vhost_alive(VHost) ->
10381035
end.
10391036

10401037
check_user_login(VHost, Username, Password, ClientId, PeerIp, ConnName) ->
1038+
AuthProps0 = [{vhost, VHost},
1039+
{client_id, ClientId}],
10411040
AuthProps = case Password of
1042-
none ->
1043-
%% SSL user name provided.
1044-
%% Authenticating using username only.
1045-
[];
1046-
_ ->
1047-
[{password, Password},
1048-
{vhost, VHost},
1049-
{client_id, ClientId}]
1041+
none -> AuthProps0;
1042+
_ -> AuthProps0 ++ [{password, Password}]
10501043
end,
10511044
case rabbit_access_control:check_user_login(Username, AuthProps) of
10521045
{ok, User = #user{username = Username1}} ->

deps/rabbitmq_mqtt/test/auth_SUITE.erl

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,13 @@
2828

2929
all() ->
3030
[
31-
{group, v4}
32-
%{group, v4},
33-
%{group, v5}
31+
{group, v4},
32+
{group, v5}
3433
].
3534

36-
test() ->
37-
[
38-
{ssl_user, [shuffle],
39-
[ user_credentials_auth ]
40-
},
41-
{ssl_user_with_client_id_in_cert, [],
42-
[ client_id_from_cert ]
43-
}
44-
].
4535
groups() ->
4636
[
47-
{v4, [], test()},
37+
{v4, [], sub_groups()},
4838
{v5, [], sub_groups()}
4939
].
5040

@@ -207,7 +197,7 @@ mqtt_config(ssl_user_with_client_id_in_cert) ->
207197
{rabbitmq_mqtt, [{ssl_cert_login, true},
208198
{allow_anonymous, false},
209199
{ssl_cert_client_id_from, subject_alternative_name},
210-
{ssl_cert_client_id_san_type, <<"CLIENT_ID">>}]};
200+
{ssl_cert_client_id_san_type, dns}]};
211201

212202
mqtt_config(_) ->
213203
undefined.

0 commit comments

Comments
 (0)