1## This Source Code Form is subject to the terms of the Mozilla Public 2## License, v. 2.0. If a copy of the MPL was not distributed with this 3## file, You can obtain one at https://mozilla.org/MPL/2.0/. 4## 5## Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved. 6 7defmodule RabbitMQ.CLI.Diagnostics.Commands.CertificatesCommand do 8 alias RabbitMQ.CLI.Core.DocGuide 9 @behaviour RabbitMQ.CLI.CommandBehaviour 10 11 import RabbitMQ.CLI.Core.Listeners 12 13 use RabbitMQ.CLI.Core.MergesNoDefaults 14 use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments 15 16 def run([], %{node: node_name, timeout: timeout}) do 17 case :rabbit_misc.rpc_call(node_name, :rabbit_networking, :active_listeners, [], timeout) do 18 {:error, _} = err -> 19 err 20 21 {:error, _, _} = err -> 22 err 23 24 xs when is_list(xs) -> 25 listeners = listeners_with_certificates(listeners_on(xs, node_name)) 26 27 case listeners do 28 [] -> %{} 29 _ -> Enum.map(listeners, &listener_certs/1) 30 end 31 32 other -> 33 other 34 end 35 end 36 37 use RabbitMQ.CLI.DefaultOutput 38 39 def formatter(), do: RabbitMQ.CLI.Formatters.Erlang 40 41 def usage, do: "certificates" 42 43 def usage_doc_guides() do 44 [ 45 DocGuide.configuration(), 46 DocGuide.tls() 47 ] 48 end 49 50 def help_section(), do: :configuration 51 52 def description(), do: "Displays certificates (public keys) for every listener on target node that is configured to use TLS" 53 54 def banner(_, %{node: node_name}), do: "Certificates of node #{node_name} ..." 55end 56