diff options
author | Konstantinos Kallas <konstantinos.kallas@hotmail.com> | 2017-08-11 14:10:55 +0300 |
---|---|---|
committer | Konstantinos Kallas <konstantinos.kallas@hotmail.com> | 2017-08-11 14:10:55 +0300 |
commit | 1aadb797b38a08b122f97935ad6061156019b30e (patch) | |
tree | e49c8e6c86fbf57aed4defd852809a969da43fc8 /src/ejabberd_acme.erl | |
parent | Format expired certificates differently in list_certificates (diff) |
Remove the new account option from get certificate. There is no reason for having this
Diffstat (limited to '')
-rw-r--r-- | src/ejabberd_acme.erl | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/ejabberd_acme.erl b/src/ejabberd_acme.erl index e84493beb..2370dc906 100644 --- a/src/ejabberd_acme.erl +++ b/src/ejabberd_acme.erl @@ -1,7 +1,7 @@ -module (ejabberd_acme). -export([%% Ejabberdctl Commands - get_certificates/3, + get_certificates/2, renew_certificates/1, list_certificates/1, revoke_certificate/2, @@ -60,10 +60,10 @@ is_valid_domain_opt(DomainString) -> %% Get Certificate %% --spec get_certificates(url(), domains_opt(), account_opt()) -> string() | {'error', _}. -get_certificates(CAUrl, Domains, NewAccountOpt) -> +-spec get_certificates(url(), domains_opt()) -> string() | {'error', _}. +get_certificates(CAUrl, Domains) -> try - get_certificates0(CAUrl, Domains, NewAccountOpt) + get_certificates0(CAUrl, Domains) catch throw:Throw -> Throw; @@ -72,18 +72,22 @@ get_certificates(CAUrl, Domains, NewAccountOpt) -> {error, get_certificates} end. --spec get_certificates0(url(), domains_opt(), account_opt()) -> string(). -get_certificates0(CAUrl, Domains, "old-account") -> - %% Get the current account - {ok, _AccId, PrivateKey} = ensure_account_exists(), +-spec get_certificates0(url(), domains_opt()) -> string(). +get_certificates0(CAUrl, Domains) -> + %% Check if an account exists or create another one + {ok, _AccId, PrivateKey} = retrieve_or_create_account(CAUrl), - get_certificates1(CAUrl, Domains, PrivateKey); + get_certificates1(CAUrl, Domains, PrivateKey). -get_certificates0(CAUrl, Domains, "new-account") -> - %% Create a new account and save it to disk - {ok, _Id, PrivateKey} = create_save_new_account(CAUrl), - get_certificates1(CAUrl, Domains, PrivateKey). +retrieve_or_create_account(CAUrl) -> + case read_account_persistent() of + none -> + create_save_new_account(CAUrl); + {ok, AccId, PrivateKey} -> + {ok, AccId, PrivateKey} + end. + -spec get_certificates1(url(), domains_opt(), jose_jwk:key()) -> string(). get_certificates1(CAUrl, "all", PrivateKey) -> |