mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-18 22:15:20 +02:00
Add a stub for the list-certificates command
This commit is contained in:
parent
09c3496ff1
commit
8fe551cc68
|
@ -2,8 +2,10 @@
|
|||
|
||||
-export([%% Ejabberdctl Commands
|
||||
get_certificates/2,
|
||||
list_certificates/1,
|
||||
%% Command Options Validity
|
||||
is_valid_account_opt/1,
|
||||
is_valid_verbose_opt/1,
|
||||
%% Misc
|
||||
generate_key/0,
|
||||
%% Debugging Scenarios
|
||||
|
@ -39,6 +41,23 @@ is_valid_account_opt("old-account") -> true;
|
|||
is_valid_account_opt("new-account") -> true;
|
||||
is_valid_account_opt(_) -> false.
|
||||
|
||||
-spec is_valid_verbose_opt(string()) -> boolean().
|
||||
is_valid_verbose_opt("plain") -> true;
|
||||
is_valid_verbose_opt("verbose") -> true;
|
||||
is_valid_verbose_opt(_) -> false.
|
||||
|
||||
%%
|
||||
%% List Certificates
|
||||
%%
|
||||
|
||||
list_certificates(Verbose) ->
|
||||
{ok, Certs} = read_certificates_persistent(),
|
||||
case Verbose of
|
||||
"plain" ->
|
||||
[{Domain, certificate} || {Domain, _Cert} <- Certs];
|
||||
"verbose" ->
|
||||
Certs
|
||||
end.
|
||||
|
||||
%%
|
||||
%% Get Certificate
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
import_file/1, import_dir/1,
|
||||
%% Acme
|
||||
get_certificate/1,
|
||||
list_certificates/1,
|
||||
%% Purge DB
|
||||
delete_expired_messages/0, delete_old_messages/1,
|
||||
%% Mnesia
|
||||
|
@ -251,6 +252,15 @@ get_commands_spec() ->
|
|||
args_desc = ["Whether to create a new account or use the existing one"],
|
||||
args = [{option, string}],
|
||||
result = {certificate, string}},
|
||||
#ejabberd_commands{name = list_certificates, tags = [acme],
|
||||
desc = "Lists all curently handled certificates and their respective domains",
|
||||
module = ?MODULE, function = list_certificates,
|
||||
args_desc = ["Whether to print the whole certificate or just some metadata. Possible values: plain | verbose"],
|
||||
args = [{option, string}],
|
||||
result = {certificates, {list,
|
||||
{certificate, {tuple,
|
||||
[{domain, string},
|
||||
{cert, string}]}}}}},
|
||||
|
||||
#ejabberd_commands{name = import_piefxis, tags = [mnesia],
|
||||
desc = "Import users data from a PIEFXIS file (XEP-0227)",
|
||||
|
@ -564,6 +574,16 @@ get_certificate(UseNewAccount) ->
|
|||
{invalid_option, String}
|
||||
end.
|
||||
|
||||
list_certificates(Verbose) ->
|
||||
case ejabberd_acme:is_valid_verbose_opt(Verbose) of
|
||||
true ->
|
||||
ejabberd_acme:list_certificates(Verbose);
|
||||
false ->
|
||||
String = io_lib:format("Invalid verbose option: ~p", [Verbose]),
|
||||
{invalid_option, String}
|
||||
end.
|
||||
|
||||
|
||||
%%%
|
||||
%%% Purge DB
|
||||
%%%
|
||||
|
|
Loading…
Reference in New Issue
Block a user