25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Repair hosts check during certfiles validation

This commit is contained in:
Evgeniy Khramtsov 2017-12-28 21:36:57 +03:00
parent 529d6d8a93
commit 240977a0da

View File

@ -120,6 +120,15 @@ format_error(Why) ->
-spec get_certfile(binary()) -> {ok, binary()} | error. -spec get_certfile(binary()) -> {ok, binary()} | error.
get_certfile(Domain) -> get_certfile(Domain) ->
case get_certfile_no_default(Domain) of
{ok, Path} ->
{ok, Path};
error ->
get_default_certfile()
end.
-spec get_certfile_no_default(binary()) -> {ok, binary()} | error.
get_certfile_no_default(Domain) ->
case ejabberd_idna:domain_utf8_to_ascii(Domain) of case ejabberd_idna:domain_utf8_to_ascii(Domain) of
false -> false ->
error; error;
@ -132,10 +141,10 @@ get_certfile(Domain) ->
[{_, Path}|_] -> [{_, Path}|_] ->
{ok, Path}; {ok, Path};
[] -> [] ->
get_default_certfile() error
end; end;
_ -> _ ->
get_default_certfile() error
end; end;
[{_, Path}|_] -> [{_, Path}|_] ->
{ok, Path} {ok, Path}
@ -240,7 +249,7 @@ handle_call({add_certfile, Path}, _, State) ->
handle_call({route_registered, Host}, _, State) -> handle_call({route_registered, Host}, _, State) ->
case add_certfiles(Host, State) of case add_certfiles(Host, State) of
{ok, NewState} -> {ok, NewState} ->
case get_certfile(Host) of case get_certfile_no_default(Host) of
{ok, _} -> ok; {ok, _} -> ok;
error -> error ->
?WARNING_MSG("No certificate found matching '~s': strictly " ?WARNING_MSG("No certificate found matching '~s': strictly "