fix(crl): allow specifying CRL URLs per listener
This commit is contained in:
parent
86278c99a6
commit
26d2ed3d31
|
@ -1702,6 +1702,11 @@ end}.
|
|||
{datatype, {enum, [true, false]}}
|
||||
]}.
|
||||
|
||||
{mapping, "listener.ssl.$name.crl_cache_urls", "emqx.listeners", [
|
||||
{default, ""},
|
||||
{datatype, string}
|
||||
]}.
|
||||
|
||||
{mapping, "listener.ssl.$name.crl_cache_http_timeout", "emqx.listeners", [
|
||||
{default, "15s"},
|
||||
{datatype, {duration, ms}}
|
||||
|
@ -1712,16 +1717,6 @@ end}.
|
|||
{datatype, {duration, ms}}
|
||||
]}.
|
||||
|
||||
{mapping, "crl_cache.urls", "emqx.crl_cache_urls", [
|
||||
{default, ""},
|
||||
{datatype, string}
|
||||
]}.
|
||||
|
||||
{translation, "emqx.crl_cache_urls", fun(Conf) ->
|
||||
Val = cuttlefish:conf_get("crl_cache.urls", Conf),
|
||||
string:tokens(Val, ", ")
|
||||
end}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% MQTT/WebSocket Listeners
|
||||
|
||||
|
@ -2364,7 +2359,16 @@ end}.
|
|||
{hibernate_after, cuttlefish:conf_get(Prefix ++ ".hibernate_after", Conf, undefined)}
|
||||
])
|
||||
end,
|
||||
|
||||
CRLOpts =
|
||||
fun(Prefix) ->
|
||||
CRLURLs = case cuttlefish:conf_get(Prefix ++ ".crl_cache_urls", Conf, undefined) of
|
||||
undefined -> undefined;
|
||||
URLs -> string:tokens(URLs, ", ")
|
||||
end,
|
||||
Filter([ {crl_cache_enabled, cuttlefish:conf_get(Prefix ++ ".enable_crl_cache", Conf, false)}
|
||||
, {crl_cache_urls, CRLURLs}
|
||||
])
|
||||
end,
|
||||
Listen_fix = fun({Ip, Port}) -> case inet:parse_address(Ip) of
|
||||
{ok, R} -> {R, Port};
|
||||
_ -> {Ip, Port}
|
||||
|
@ -2400,6 +2404,7 @@ end}.
|
|||
, opts => [ {deflate_options, DeflateOpts(Prefix)}
|
||||
, {tcp_options, TcpOpts(Prefix)}
|
||||
, {ssl_options, SslOpts(Prefix)}
|
||||
, {crl_options, CRLOpts(Prefix)}
|
||||
| LisOpts(Prefix)
|
||||
]
|
||||
}
|
||||
|
|
|
@ -54,7 +54,8 @@
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
start_link() ->
|
||||
URLs = emqx:get_env(crl_cache_urls, []),
|
||||
Listeners = emqx:get_env(listeners, []),
|
||||
URLs = collect_urls(Listeners),
|
||||
RefreshIntervalMS0 = emqx:get_env(crl_cache_refresh_interval,
|
||||
timer:minutes(15)),
|
||||
MinimumRefreshInverval = timer:minutes(1),
|
||||
|
@ -177,3 +178,11 @@ ensure_timer(URL, State = #state{refresh_timers = RefreshTimers0}, Timeout) ->
|
|||
Timeout,
|
||||
{refresh, URL})},
|
||||
State#state{refresh_timers = RefreshTimers}.
|
||||
|
||||
collect_urls(Listeners) ->
|
||||
lists:usort([URL
|
||||
|| #{proto := ssl, opts := Opts} <- Listeners,
|
||||
{crl_options, CRLOpts} <- Opts,
|
||||
proplists:get_bool(crl_cache_enabled, CRLOpts),
|
||||
{crl_cache_urls, URLs} <- CRLOpts,
|
||||
URL <- URLs]).
|
||||
|
|
|
@ -79,13 +79,21 @@ end_per_testcase(TestCase, Config)
|
|||
ServerPid = ?config(http_server, Config),
|
||||
emqx_crl_cache_http_server:stop(ServerPid),
|
||||
emqx_ct_helpers:stop_apps([]),
|
||||
application:set_env(emqx, crl_cache_urls, []),
|
||||
emqx_ct_helpers:change_emqx_opts(
|
||||
ssl_twoway, [ {crl_options, [ {crl_cache_enabled, false}
|
||||
, {crl_cache_urls, []}
|
||||
]}
|
||||
]),
|
||||
application:stop(cowboy),
|
||||
clear_crl_cache(),
|
||||
ok;
|
||||
end_per_testcase(t_not_cached_and_unreachable, _Config) ->
|
||||
emqx_ct_helpers:stop_apps([]),
|
||||
application:set_env(emqx, crl_cache_urls, []),
|
||||
emqx_ct_helpers:change_emqx_opts(
|
||||
ssl_twoway, [ {crl_options, [ {crl_cache_enabled, false}
|
||||
, {crl_cache_urls, []}
|
||||
]}
|
||||
]),
|
||||
clear_crl_cache(),
|
||||
ok;
|
||||
end_per_testcase(_TestCase, _Config) ->
|
||||
|
@ -177,7 +185,6 @@ setup_crl_options(Config, #{is_cached := IsCached}) ->
|
|||
end,
|
||||
Handler =
|
||||
fun(emqx) ->
|
||||
application:set_env(emqx, crl_cache_urls, URLs),
|
||||
emqx_ct_helpers:change_emqx_opts(
|
||||
ssl_twoway, [ {ssl_options, [ {certfile, Certfile}
|
||||
, {keyfile, Keyfile}
|
||||
|
@ -186,7 +193,11 @@ setup_crl_options(Config, #{is_cached := IsCached}) ->
|
|||
, {crl_check, peer}
|
||||
, {crl_cache,
|
||||
{ssl_crl_cache, {internal, [{http, timer:seconds(15)}]}}}
|
||||
]}]),
|
||||
]}
|
||||
, {crl_options, [ {crl_cache_enabled, true}
|
||||
, {crl_cache_urls, URLs}
|
||||
]}
|
||||
]),
|
||||
%% emqx_ct_helpers:change_emqx_opts has cacertfile hardcoded....
|
||||
ok = force_cacertfile(Cacertfile),
|
||||
ok;
|
||||
|
|
Loading…
Reference in New Issue