fix(quic): environment variables as cert file prefix for quic listener

This commit is contained in:
Zaiming (Stone) Shi 2023-06-10 11:52:03 +02:00
parent 4215da12f0
commit 9f135d1f2b
3 changed files with 12 additions and 5 deletions

View File

@ -423,8 +423,8 @@ do_start_listener(quic, ListenerName, #{bind := Bind} = Opts) ->
), ),
ListenOpts = ListenOpts =
[ [
{certfile, str(maps:get(certfile, SSLOpts))}, {certfile, emqx_schema:naive_env_interpolation(maps:get(certfile, SSLOpts))},
{keyfile, str(maps:get(keyfile, SSLOpts))}, {keyfile, emqx_schema:naive_env_interpolation(maps:get(keyfile, SSLOpts))},
{alpn, ["mqtt"]}, {alpn, ["mqtt"]},
{conn_acceptors, lists:max([DefAcceptors, maps:get(acceptors, Opts, 0)])}, {conn_acceptors, lists:max([DefAcceptors, maps:get(acceptors, Opts, 0)])},
{keep_alive_interval_ms, maps:get(keep_alive_interval, Opts, 0)}, {keep_alive_interval_ms, maps:get(keep_alive_interval, Opts, 0)},
@ -434,8 +434,10 @@ do_start_listener(quic, ListenerName, #{bind := Bind} = Opts) ->
{verify, maps:get(verify, SSLOpts, verify_none)} {verify, maps:get(verify, SSLOpts, verify_none)}
] ++ ] ++
case maps:get(cacertfile, SSLOpts, undefined) of case maps:get(cacertfile, SSLOpts, undefined) of
undefined -> []; undefined ->
CaCertFile -> [{cacertfile, str(CaCertFile)}] [];
CaCertFile ->
[{cacertfile, emqx_schema:naive_env_interpolation(CaCertFile)}]
end ++ end ++
case maps:get(password, SSLOpts, undefined) of case maps:get(password, SSLOpts, undefined) of
undefined -> []; undefined -> [];

View File

@ -1435,7 +1435,9 @@ fields("listener_quic_ssl_opts") ->
true -> true ->
{Name, Schema}; {Name, Schema};
false -> false ->
{Name, Schema#{deprecated => {since, "5.0.20"}}} {Name, Schema#{
deprecated => {since, "5.0.20"}, importance => ?IMPORTANCE_HIDDEN
}}
end end
end, end,
Schema1 Schema1

View File

@ -0,0 +1,3 @@
Fix QUIC listeners's default cert file paths.
Prior to this change, the default cert file paths are prefixed with environment variable `${EMQX_ETC_DIR}` which were not interpolated before used in QUIC listeners.