mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Add acme certificates for all configured hosts in ejabberd_pkix
This commit is contained in:
parent
ddfe8742c7
commit
7cc7b74f1e
@ -10,6 +10,8 @@
|
|||||||
is_valid_verbose_opt/1,
|
is_valid_verbose_opt/1,
|
||||||
is_valid_domain_opt/1,
|
is_valid_domain_opt/1,
|
||||||
is_valid_revoke_cert/1,
|
is_valid_revoke_cert/1,
|
||||||
|
%% Called by ejabberd_pkix
|
||||||
|
certificate_exists/1,
|
||||||
%% Key Related
|
%% Key Related
|
||||||
generate_key/0,
|
generate_key/0,
|
||||||
to_public/1
|
to_public/1
|
||||||
@ -539,6 +541,25 @@ domain_certificate_exists(Domain) ->
|
|||||||
lists:keyfind(Domain, 1, Certs).
|
lists:keyfind(Domain, 1, Certs).
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%%
|
||||||
|
%% Called by ejabberd_pkix to check
|
||||||
|
%% if a certificate exists for a
|
||||||
|
%% specific host
|
||||||
|
%%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
-spec certificate_exists(bitstring()) -> {true, file:filename()} | false.
|
||||||
|
certificate_exists(Host) ->
|
||||||
|
Certificates = read_certificates_persistent(),
|
||||||
|
case lists:keyfind(Host, 1 , Certificates) of
|
||||||
|
false ->
|
||||||
|
false;
|
||||||
|
{Host, #data_cert{path=Path}} ->
|
||||||
|
{true, Path}
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%%
|
%%
|
||||||
%% Certificate Request Functions
|
%% Certificate Request Functions
|
||||||
|
@ -204,15 +204,24 @@ add_certfiles(State) ->
|
|||||||
end, State, ejabberd_config:get_myhosts()).
|
end, State, ejabberd_config:get_myhosts()).
|
||||||
|
|
||||||
add_certfiles(Host, State) ->
|
add_certfiles(Host, State) ->
|
||||||
lists:foldl(
|
NewState =
|
||||||
fun(Opt, AccState) ->
|
lists:foldl(
|
||||||
case ejabberd_config:get_option({Opt, Host}) of
|
fun(Opt, AccState) ->
|
||||||
undefined -> AccState;
|
case ejabberd_config:get_option({Opt, Host}) of
|
||||||
Path ->
|
undefined -> AccState;
|
||||||
{_, NewAccState} = add_certfile(Path, AccState),
|
Path ->
|
||||||
NewAccState
|
{_, NewAccState} = add_certfile(Path, AccState),
|
||||||
end
|
NewAccState
|
||||||
end, State, [c2s_certfile, s2s_certfile, domain_certfile]).
|
end
|
||||||
|
end, State, [c2s_certfile, s2s_certfile, domain_certfile]),
|
||||||
|
%% Add acme certificate if it exists
|
||||||
|
case ejabberd_acme:certificate_exists(Host) of
|
||||||
|
{true, Path} ->
|
||||||
|
{_, FinalState} = add_certfile(Path, NewState),
|
||||||
|
FinalState;
|
||||||
|
false ->
|
||||||
|
NewState
|
||||||
|
end.
|
||||||
|
|
||||||
add_certfile(Path, State) ->
|
add_certfile(Path, State) ->
|
||||||
case maps:get(Path, State#state.certs, undefined) of
|
case maps:get(Path, State#state.certs, undefined) of
|
||||||
|
Loading…
Reference in New Issue
Block a user