mirror of
https://github.com/processone/ejabberd
synced 2025-10-05 10:39:29 +02:00
Add a stub for the list-certificates command
This commit is contained in:
parent
09c3496ff1
commit
8fe551cc68
2 changed files with 39 additions and 0 deletions
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
-export([%% Ejabberdctl Commands
|
-export([%% Ejabberdctl Commands
|
||||||
get_certificates/2,
|
get_certificates/2,
|
||||||
|
list_certificates/1,
|
||||||
%% Command Options Validity
|
%% Command Options Validity
|
||||||
is_valid_account_opt/1,
|
is_valid_account_opt/1,
|
||||||
|
is_valid_verbose_opt/1,
|
||||||
%% Misc
|
%% Misc
|
||||||
generate_key/0,
|
generate_key/0,
|
||||||
%% Debugging Scenarios
|
%% Debugging Scenarios
|
||||||
|
@ -39,6 +41,23 @@ is_valid_account_opt("old-account") -> true;
|
||||||
is_valid_account_opt("new-account") -> true;
|
is_valid_account_opt("new-account") -> true;
|
||||||
is_valid_account_opt(_) -> false.
|
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
|
%% Get Certificate
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
import_file/1, import_dir/1,
|
import_file/1, import_dir/1,
|
||||||
%% Acme
|
%% Acme
|
||||||
get_certificate/1,
|
get_certificate/1,
|
||||||
|
list_certificates/1,
|
||||||
%% Purge DB
|
%% Purge DB
|
||||||
delete_expired_messages/0, delete_old_messages/1,
|
delete_expired_messages/0, delete_old_messages/1,
|
||||||
%% Mnesia
|
%% Mnesia
|
||||||
|
@ -251,6 +252,15 @@ get_commands_spec() ->
|
||||||
args_desc = ["Whether to create a new account or use the existing one"],
|
args_desc = ["Whether to create a new account or use the existing one"],
|
||||||
args = [{option, string}],
|
args = [{option, string}],
|
||||||
result = {certificate, 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],
|
#ejabberd_commands{name = import_piefxis, tags = [mnesia],
|
||||||
desc = "Import users data from a PIEFXIS file (XEP-0227)",
|
desc = "Import users data from a PIEFXIS file (XEP-0227)",
|
||||||
|
@ -564,6 +574,16 @@ get_certificate(UseNewAccount) ->
|
||||||
{invalid_option, String}
|
{invalid_option, String}
|
||||||
end.
|
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
|
%%% Purge DB
|
||||||
%%%
|
%%%
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue