mirror of
https://github.com/processone/ejabberd.git
synced 2025-01-03 18:02:28 +01:00
Move the ca_url to the config file
This commit is contained in:
parent
7140c8d844
commit
73f0b6707a
@ -664,11 +664,11 @@ language: "en"
|
|||||||
###' ACME
|
###' ACME
|
||||||
|
|
||||||
##
|
##
|
||||||
## Must contain a contact and a directory that the Http Challenges can be solved at
|
## Must contain a contact and the ACME CA url
|
||||||
##
|
##
|
||||||
acme:
|
acme:
|
||||||
contact: "mailto:cert-admin-ejabberd@example.com"
|
contact: "mailto:cert-admin-ejabberd@example.com"
|
||||||
http_dir: "/home/konstantinos/Desktop/Programming/test-server-for-acme/"
|
ca_url: "http://localhost:4000"
|
||||||
|
|
||||||
cert_dir: "/usr/local/var/lib/ejabberd/"
|
cert_dir: "/usr/local/var/lib/ejabberd/"
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
-module (ejabberd_acme).
|
-module (ejabberd_acme).
|
||||||
|
|
||||||
-export([%% Ejabberdctl Commands
|
-export([%% Ejabberdctl Commands
|
||||||
get_certificates/3,
|
get_certificates/2,
|
||||||
renew_certificates/1,
|
renew_certificates/0,
|
||||||
list_certificates/1,
|
list_certificates/1,
|
||||||
revoke_certificate/2,
|
revoke_certificate/1,
|
||||||
%% Command Options Validity
|
%% Command Options Validity
|
||||||
is_valid_account_opt/1,
|
is_valid_account_opt/1,
|
||||||
is_valid_verbose_opt/1,
|
is_valid_verbose_opt/1,
|
||||||
@ -60,9 +60,10 @@ is_valid_domain_opt(DomainString) ->
|
|||||||
%% Get Certificate
|
%% Get Certificate
|
||||||
%%
|
%%
|
||||||
|
|
||||||
-spec get_certificates(url(), domains_opt(), account_opt()) -> string() | {'error', _}.
|
-spec get_certificates(domains_opt(), account_opt()) -> string() | {'error', _}.
|
||||||
get_certificates(CAUrl, Domains, NewAccountOpt) ->
|
get_certificates(Domains, NewAccountOpt) ->
|
||||||
try
|
try
|
||||||
|
CAUrl = binary_to_list(get_config_ca_url()),
|
||||||
get_certificates0(CAUrl, Domains, NewAccountOpt)
|
get_certificates0(CAUrl, Domains, NewAccountOpt)
|
||||||
catch
|
catch
|
||||||
throw:Throw ->
|
throw:Throw ->
|
||||||
@ -266,9 +267,10 @@ ensure_account_exists() ->
|
|||||||
%%
|
%%
|
||||||
%% Renew Certificates
|
%% Renew Certificates
|
||||||
%%
|
%%
|
||||||
-spec renew_certificates(url()) -> string() | {'error', _}.
|
-spec renew_certificates() -> string() | {'error', _}.
|
||||||
renew_certificates(CAUrl) ->
|
renew_certificates() ->
|
||||||
try
|
try
|
||||||
|
CAUrl = binary_to_list(get_config_ca_url()),
|
||||||
renew_certificates0(CAUrl)
|
renew_certificates0(CAUrl)
|
||||||
catch
|
catch
|
||||||
throw:Throw ->
|
throw:Throw ->
|
||||||
@ -454,10 +456,10 @@ get_utc_validity(#'Certificate'{tbsCertificate = TbsCertificate}) ->
|
|||||||
%% Revoke Certificate
|
%% Revoke Certificate
|
||||||
%%
|
%%
|
||||||
|
|
||||||
%% Add a try-catch to this stub
|
-spec revoke_certificate(string()) -> {ok, deleted} | {error, _}.
|
||||||
-spec revoke_certificate(url(), string()) -> {ok, deleted} | {error, _}.
|
revoke_certificate(Domain) ->
|
||||||
revoke_certificate(CAUrl, Domain) ->
|
|
||||||
try
|
try
|
||||||
|
CAUrl = binary_to_list(get_config_ca_url()),
|
||||||
revoke_certificate0(CAUrl, Domain)
|
revoke_certificate0(CAUrl, Domain)
|
||||||
catch
|
catch
|
||||||
throw:Throw ->
|
throw:Throw ->
|
||||||
@ -968,6 +970,18 @@ get_config_contact() ->
|
|||||||
throw({error, configuration_contact})
|
throw({error, configuration_contact})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec get_config_ca_url() -> bitstring().
|
||||||
|
get_config_ca_url() ->
|
||||||
|
Acme = get_config_acme(),
|
||||||
|
case lists:keyfind(ca_url, 1, Acme) of
|
||||||
|
{ca_url, CAUrl} ->
|
||||||
|
CAUrl;
|
||||||
|
false ->
|
||||||
|
?ERROR_MSG("No CA url has been specified", []),
|
||||||
|
throw({error, configuration_ca_url})
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
-spec get_config_hosts() -> [bitstring()].
|
-spec get_config_hosts() -> [bitstring()].
|
||||||
get_config_hosts() ->
|
get_config_hosts() ->
|
||||||
case ejabberd_config:get_option(hosts, undefined) of
|
case ejabberd_config:get_option(hosts, undefined) of
|
||||||
|
@ -582,7 +582,7 @@ get_certificate(Domains, UseNewAccount) ->
|
|||||||
true ->
|
true ->
|
||||||
case ejabberd_acme:is_valid_account_opt(UseNewAccount) of
|
case ejabberd_acme:is_valid_account_opt(UseNewAccount) of
|
||||||
true ->
|
true ->
|
||||||
ejabberd_acme:get_certificates("http://localhost:4000", Domains, UseNewAccount);
|
ejabberd_acme:get_certificates(Domains, UseNewAccount);
|
||||||
false ->
|
false ->
|
||||||
io_lib:format("Invalid account option: ~p", [UseNewAccount])
|
io_lib:format("Invalid account option: ~p", [UseNewAccount])
|
||||||
end;
|
end;
|
||||||
@ -591,7 +591,7 @@ get_certificate(Domains, UseNewAccount) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
renew_certificate() ->
|
renew_certificate() ->
|
||||||
ejabberd_acme:renew_certificates("http://localhost:4000").
|
ejabberd_acme:renew_certificates().
|
||||||
|
|
||||||
list_certificates(Verbose) ->
|
list_certificates(Verbose) ->
|
||||||
case ejabberd_acme:is_valid_verbose_opt(Verbose) of
|
case ejabberd_acme:is_valid_verbose_opt(Verbose) of
|
||||||
@ -603,7 +603,7 @@ list_certificates(Verbose) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
revoke_certificate(Domain) ->
|
revoke_certificate(Domain) ->
|
||||||
ejabberd_acme:revoke_certificate("http://localhost:4000", Domain).
|
ejabberd_acme:revoke_certificate(Domain).
|
||||||
|
|
||||||
%%%
|
%%%
|
||||||
%%% Purge DB
|
%%% Purge DB
|
||||||
|
Loading…
Reference in New Issue
Block a user