fix: reload ssl listener failed

This commit is contained in:
Zhongwen Deng 2022-06-07 22:18:21 +08:00
parent 5e92ef54c5
commit 853ead3aaf
3 changed files with 8 additions and 4 deletions

View File

@ -557,18 +557,18 @@ certs_dir(Type, Name) ->
iolist_to_binary(filename:join(["listeners", Type, Name])). iolist_to_binary(filename:join(["listeners", Type, Name])).
convert_certs(CertsDir, Conf) -> convert_certs(CertsDir, Conf) ->
case emqx_tls_lib:ensure_ssl_files(CertsDir, maps:get(<<"ssl">>, Conf, undefined)) of case emqx_tls_lib:ensure_ssl_files(CertsDir, maps:get(<<"ssl_options">>, Conf, undefined)) of
{ok, undefined} -> {ok, undefined} ->
Conf; Conf;
{ok, SSL} -> {ok, SSL} ->
Conf#{<<"ssl">> => SSL}; Conf#{<<"ssl_options">> => SSL};
{error, Reason} -> {error, Reason} ->
?SLOG(error, Reason#{msg => "bad_ssl_config"}), ?SLOG(error, Reason#{msg => "bad_ssl_config"}),
throw({bad_ssl_config, Reason}) throw({bad_ssl_config, Reason})
end. end.
clear_certs(CertsDir, Conf) -> clear_certs(CertsDir, Conf) ->
OldSSL = maps:get(<<"ssl">>, Conf, undefined), OldSSL = maps:get(<<"ssl_options">>, Conf, undefined),
emqx_tls_lib:delete_ssl_files(CertsDir, undefined, OldSSL). emqx_tls_lib:delete_ssl_files(CertsDir, undefined, OldSSL).
filter_stacktrace({Reason, _Stacktrace}) -> Reason; filter_stacktrace({Reason, _Stacktrace}) -> Reason;

View File

@ -70,6 +70,9 @@ init_per_group(_, Config) ->
emqx_common_test_helpers:stop_apps([]), emqx_common_test_helpers:stop_apps([]),
Config. Config.
end_per_group(quic, _Config) ->
emqx_config:put([listeners, quic], #{}),
ok;
end_per_group(_Group, _Config) -> end_per_group(_Group, _Config) ->
ok. ok.

View File

@ -33,9 +33,10 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_channel_SUITE:set_test_listener_confs(),
?check_trace( ?check_trace(
?wait_async_action( ?wait_async_action(
emqx_common_test_helpers:start_apps([emqx_conf]), emqx_common_test_helpers:start_apps([]),
#{?snk_kind := listener_started, bind := 1883}, #{?snk_kind := listener_started, bind := 1883},
timer:seconds(10) timer:seconds(10)
), ),