Skip to content

Commit 4fb58bc

Browse files
committed
Add crl_cache support to rabbitmq.conf configuration
RabbitMQ's modern `rabbitmq.conf` format does not support the `crl_cache` SSL option, forcing users to fall back to the legacy Erlang-style `advanced.config` file for this single setting. This creates an inconsistent configuration experience when using Certificate Revocation List (CRL) validation. This adds schema mappings for `ssl_options.crl_sources` using indexed syntax. The implementation translates these settings into the required Erlang term format `{crl_cache, {ssl_crl_cache, {internal, [Options]}}}`. Two CRL source types are supported: `http` with an optional `timeout` parameter (defaults to 5000ms), and `dir` with a required `path` parameter. Validation ensures that only appropriate options are used with each source type. Users can now configure multiple CRL sources using indexed syntax: ``` ssl_options.crl_sources.0 = http ssl_options.crl_sources.0.timeout = 5000 ssl_options.crl_sources.1 = dir ssl_options.crl_sources.1.path = /var/lib/rabbitmq/crls ``` Fixes #2338
1 parent fd34831 commit 4fb58bc

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

deps/rabbit/priv/schema/rabbit.schema

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,50 @@ end}.
335335
{mapping, "ssl_options.crl_check", "rabbit.ssl_options.crl_check",
336336
[{datatype, [{enum, [true, false, peer, best_effort]}]}]}.
337337

338+
{mapping, "ssl_options.crl_sources.$index", "rabbit.ssl_options.crl_cache",
339+
[{datatype, {enum, [http, dir]}}]}.
340+
341+
{mapping, "ssl_options.crl_sources.$index.timeout", "rabbit.ssl_options.crl_cache",
342+
[{datatype, integer}]}.
343+
344+
{mapping, "ssl_options.crl_sources.$index.path", "rabbit.ssl_options.crl_cache",
345+
[{datatype, string}]}.
346+
347+
{translation, "rabbit.ssl_options.crl_cache",
348+
fun(Conf) ->
349+
Entries = cuttlefish_variable:filter_by_prefix("ssl_options.crl_sources", Conf),
350+
case Entries of
351+
[] -> cuttlefish:unset();
352+
_ ->
353+
Sources = lists:foldl(
354+
fun({[_, _, Index, Opt], Val}, Acc) ->
355+
K = list_to_atom(Index),
356+
[{K, {list_to_existing_atom(Opt), Val}} | Acc];
357+
({[_, _, Index], Val}, Acc) ->
358+
K = list_to_atom(Index),
359+
[{K, {type, Val}} | Acc]
360+
end, [], Entries),
361+
Grouped = maps:to_list(maps:groups_from_list(fun({K, _}) -> K end, fun({_, V}) -> V end, Sources)),
362+
CrlOpts = lists:map(
363+
fun({_, Props}) ->
364+
Type = proplists:get_value(type, Props),
365+
case Type of
366+
http ->
367+
case proplists:get_keys(Props) -- [type, timeout] of
368+
[] -> {http, proplists:get_value(timeout, Props, 5000)};
369+
_ -> cuttlefish:invalid("http source only supports 'timeout' option")
370+
end;
371+
dir ->
372+
case proplists:get_keys(Props) -- [type, path] of
373+
[] -> {dir, proplists:get_value(path, Props)};
374+
_ -> cuttlefish:invalid("dir source only supports 'path' option")
375+
end
376+
end
377+
end, Grouped),
378+
{ssl_crl_cache, {internal, CrlOpts}}
379+
end
380+
end}.
381+
338382
{mapping, "ssl_options.depth", "rabbit.ssl_options.depth",
339383
[{datatype, integer}, {validators, ["byte"]}]}.
340384

deps/rabbit/test/config_schema_SUITE_data/rabbit.snippets

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,35 @@ ssl_options.fail_if_no_peer_cert = true",
8383
{verify,verify_peer},
8484
{fail_if_no_peer_cert,true}]}]}],
8585
[]},
86+
{ssl_options_crl_cache_http,
87+
"ssl_options.crl_check = true
88+
ssl_options.crl_sources.0 = http
89+
ssl_options.crl_sources.0.timeout = 5000",
90+
[{rabbit,
91+
[{ssl_options,
92+
[{crl_check,true},
93+
{crl_cache,{ssl_crl_cache,{internal,[{http,5000}]}}}]}]}],
94+
[]},
95+
{ssl_options_crl_cache_dir,
96+
"ssl_options.crl_check = true
97+
ssl_options.crl_sources.0 = dir
98+
ssl_options.crl_sources.0.path = /var/lib/rabbitmq/crls",
99+
[{rabbit,
100+
[{ssl_options,
101+
[{crl_check,true},
102+
{crl_cache,{ssl_crl_cache,{internal,[{dir,"/var/lib/rabbitmq/crls"}]}}}]}]}],
103+
[]},
104+
{ssl_options_crl_cache_both,
105+
"ssl_options.crl_check = true
106+
ssl_options.crl_sources.0 = http
107+
ssl_options.crl_sources.0.timeout = 5000
108+
ssl_options.crl_sources.1 = dir
109+
ssl_options.crl_sources.1.path = /var/lib/rabbitmq/crls",
110+
[{rabbit,
111+
[{ssl_options,
112+
[{crl_check,true},
113+
{crl_cache,{ssl_crl_cache,{internal,[{http,5000},{dir,"/var/lib/rabbitmq/crls"}]}}}]}]}],
114+
[]},
86115
{tcp_listener,
87116
"listeners.tcp.default = 5673",
88117
[{rabbit,[{tcp_listeners,[5673]}]}],[]},

0 commit comments

Comments
 (0)