Skip to content

Commit 97c00a3

Browse files
authored
Report TLS in Erlang distribution in the CLI (#15406)
follow-up to #15399 the initial PR solved the problem for the Management UI and API, but we also report listeners in the CLI. This change addresses this part.
1 parent a3115a0 commit 97c00a3

4 files changed

Lines changed: 30 additions & 14 deletions

File tree

deps/rabbit/src/rabbit_networking.erl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
-export([ensure_listener_table_for_this_node/0]).
4848

49+
-export([clustering_tls_enabled/0]).
50+
4951
-deprecated([{force_connection_event_refresh, 1, eventually}]).
5052

5153
-export([
@@ -423,7 +425,11 @@ maybe_get_epmd_port(Name, Host) ->
423425
{ok, IP} -> IP;
424426
_ -> {0,0,0,0,0,0,0,0}
425427
end,
426-
tcp_listener_started(clustering, [], IPAddress, Port);
428+
Proto = case clustering_tls_enabled() of
429+
true -> 'clustering/ssl';
430+
false -> clustering
431+
end,
432+
tcp_listener_started(Proto, [], IPAddress, Port);
427433
noport ->
428434
throw({error, no_epmd_port})
429435
end.
@@ -457,6 +463,7 @@ node_client_listeners(Node) ->
457463
[] -> [];
458464
Xs ->
459465
lists:filter(fun (#listener{protocol = clustering}) -> false;
466+
(#listener{protocol = 'clustering/ssl'}) -> false;
460467
(_) -> true
461468
end, Xs)
462469
end.
@@ -758,3 +765,11 @@ ipv6_status(TestPort) ->
758765
ensure_listener_table_for_this_node() ->
759766
_ = ets:new(?ETS_TABLE, [named_table, public, bag, {keypos, #listener.node}]),
760767
ok.
768+
769+
-spec clustering_tls_enabled() -> boolean().
770+
clustering_tls_enabled() ->
771+
case init:get_argument(proto_dist) of
772+
{ok, [["inet_tls"]]} -> true;
773+
{ok, [["inet6_tls"]]} -> true;
774+
_ -> false
775+
end.

deps/rabbitmq_cli/lib/rabbitmq/cli/core/listeners.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ defmodule RabbitMQ.CLI.Core.Listeners do
270270
def protocol_label(:"http/prometheus"), do: "Prometheus exporter API over HTTP"
271271
def protocol_label(:"https/prometheus"), do: "Prometheus exporter API over TLS (HTTPS)"
272272
def protocol_label(:clustering), do: "inter-node and CLI tool communication"
273+
def protocol_label(:"clustering/ssl"), do: "inter-node and CLI tool communication over TLS"
273274
def protocol_label(other), do: to_string(other)
274275

275276
def normalize_protocol(proto) do
@@ -315,6 +316,10 @@ defmodule RabbitMQ.CLI.Core.Listeners do
315316
"ui" -> "http"
316317
"cli" -> "clustering"
317318
"distribution" -> "clustering"
319+
"cli/ssl" -> "clustering/ssl"
320+
"cli/tls" -> "clustering/ssl"
321+
"distribution/ssl" -> "clustering/ssl"
322+
"distribution/tls" -> "clustering/ssl"
318323
"webmqtt" -> "http/web-mqtt"
319324
"web-mqtt" -> "http/web-mqtt"
320325
"web_mqtt" -> "http/web-mqtt"

deps/rabbitmq_management/src/rabbit_mgmt_wm_health_check_protocol_listener.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ normalize_protocol(Protocol) ->
109109
"ui" -> "http";
110110
"cli" -> "clustering";
111111
"distribution" -> "clustering";
112+
"cli/ssl" -> "clustering/ssl";
113+
"cli/tls" -> "clustering/ssl";
114+
"distribution/ssl" -> "clustering/ssl";
115+
"distribution/tls" -> "clustering/ssl";
112116
"webmqtt" -> "http/web-mqtt";
113117
"web-mqtt" -> "http/web-mqtt";
114118
"web_mqtt" -> "http/web-mqtt";

deps/rabbitmq_management_agent/src/rabbit_mgmt_format.erl

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,14 @@ tags_as_binaries(Tags) ->
275275

276276
listener(#listener{node = Node, protocol = Protocol,
277277
ip_address = IPAddress, port = Port, opts=Opts}) ->
278-
TlsEnabled = has_tls_enabled(Protocol, Opts),
279278
[{node, Node},
280-
{protocol, format_protocol(Protocol, TlsEnabled)},
279+
{protocol, Protocol},
281280
{ip_address, ip(IPAddress)},
282281
{port, Port},
283282
{socket_opts, format_socket_opts(Opts)},
284-
{tls, TlsEnabled}
283+
{tls, has_tls_enabled(Protocol, Opts)}
285284
].
286285

287-
format_protocol(clustering, true) -> 'clustering/ssl';
288-
format_protocol(Protocol, _) -> Protocol.
289-
290286
web_context(Props0) ->
291287
SslOpts0 = pget(ssl_opts, Props0, []),
292288

@@ -298,14 +294,10 @@ web_context(Props0) ->
298294
Props1 = proplists:delete(ssl_opts, Props0),
299295
[{ssl_opts, format_socket_opts(SslOpts1)} | Props1].
300296

297+
has_tls_enabled('clustering/ssl', _Opts) ->
298+
true;
301299
has_tls_enabled(clustering, _Opts) ->
302-
%% Erlang distribution TLS is configured externally via the -proto_dist
303-
%% VM argument, not through RabbitMQ configuration.
304-
case init:get_argument(proto_dist) of
305-
{ok, [["inet_tls"]]} -> true;
306-
{ok, [["inet6_tls"]]} -> true;
307-
_ -> false
308-
end;
300+
false;
309301
has_tls_enabled(_Protocol, Opts) ->
310302
S = proplists:get_value(socket_opts, Opts, Opts),
311303
(proplists:get_value(ssl_opts, S, undefined) =/= undefined) orelse

0 commit comments

Comments
 (0)