|
7 | 7 |
|
8 | 8 | -module(rabbit_mgmt_format). |
9 | 9 |
|
| 10 | +-include_lib("kernel/include/logger.hrl"). |
| 11 | + |
10 | 12 | -export([format/2, ip/1, ipb/1, amqp_table/1, tuple/1]). |
11 | 13 | -export([parameter/1, now_to_str/0, now_to_str/1, strip_pids/1]). |
12 | 14 | -export([protocol/1, resource/1, queue/1, queue/2, queue_state/1, queue_info/1]). |
@@ -284,9 +286,15 @@ listener(#listener{node = Node, protocol = Protocol, |
284 | 286 | ]. |
285 | 287 |
|
286 | 288 | web_context(Props0) -> |
287 | | - SslOpts = pget(ssl_opts, Props0, []), |
288 | | - Props = proplists:delete(ssl_opts, Props0), |
289 | | - [{ssl_opts, format_socket_opts(SslOpts)} | Props]. |
| 289 | + SslOpts0 = pget(ssl_opts, Props0, []), |
| 290 | + |
| 291 | + % Note: cacerts is pre-formatted by cowboy, and is a very large binary |
| 292 | + % at this point. This fixes up the output to not show the contents of |
| 293 | + % the CA certs |
| 294 | + SslOpts1 = lists:keyreplace(cacerts, 1, SslOpts0, {cacerts, truncated}), |
| 295 | + |
| 296 | + Props1 = proplists:delete(ssl_opts, Props0), |
| 297 | + [{ssl_opts, format_socket_opts(SslOpts1)} | Props1]. |
290 | 298 |
|
291 | 299 | has_tls_enabled(Opts) -> |
292 | 300 | S = proplists:get_value(socket_opts, Opts, Opts), |
@@ -318,16 +326,16 @@ format_socket_opts([{user_lookup_fun, _Value} | Tail], Acc) -> |
318 | 326 | format_socket_opts([{sni_fun, _Value} | Tail], Acc) -> |
319 | 327 | format_socket_opts(Tail, Acc); |
320 | 328 | %% https://www.erlang.org/doc/apps/ssl/ssl.html#t:server_option_cert/0 |
321 | | -format_socket_opts([{cacerts, Cacerts} | Tail], Acc) -> |
| 329 | +format_socket_opts([{cacerts, Cacerts} | Tail], Acc) when is_list(Cacerts) -> |
322 | 330 | CacertsMsg = rabbit_data_coercion:to_utf8_binary( |
323 | 331 | io_lib:format("(~b cacerts entries)", [length(Cacerts)])), |
324 | 332 | format_socket_opts(Tail, [{cacerts, CacertsMsg} | Acc]); |
325 | 333 | %% https://www.erlang.org/doc/apps/ssl/ssl.html#t:common_option_cert/0 |
326 | 334 | %% https://www.erlang.org/doc/apps/ssl/ssl.html#t:cert_key_conf/0 |
327 | | -format_socket_opts([{certs_keys, CertsKeys} | Tail], Acc) -> |
| 335 | +format_socket_opts([{certs_keys, CertsKeys} | Tail], Acc) when is_map(CertsKeys) -> |
328 | 336 | CertsKeysMsg = rabbit_data_coercion:to_utf8_binary( |
329 | 337 | io_lib:format("(~b certs_keys entries)", [length(CertsKeys)])), |
330 | | - format_socket_opts(Tail, [{cacerts, CertsKeysMsg} | Acc]); |
| 338 | + format_socket_opts(Tail, [{certs_keys, CertsKeysMsg} | Acc]); |
331 | 339 | %% we do not report SNI host details in the UI, |
332 | 340 | %% so skip this option and avoid some recursive formatting |
333 | 341 | %% complexity |
|
0 commit comments