fix(tlsgc): consolidate conf keypaths knowledge in `emqx_tls_lib`

So that this GC mechanism will be easier to maintain.
This commit is contained in:
Andrew Mayorov 2023-06-03 00:12:10 +03:00
parent ec06850bd0
commit 3c2a7dbadc
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
2 changed files with 10 additions and 5 deletions

View File

@ -240,11 +240,11 @@ find_references(Root) ->
Config
).
is_file_reference([<<"keyfile">> | _]) -> true;
is_file_reference([<<"certfile">> | _]) -> true;
is_file_reference([<<"cacertfile">> | _]) -> true;
is_file_reference([<<"issuer_pem">>, <<"ocsp">> | _]) -> true;
is_file_reference(_) -> false.
is_file_reference(Stack) ->
lists:any(
fun(KP) -> lists:prefix(lists:reverse(KP), Stack) end,
emqx_tls_lib:ssl_file_conf_keypaths()
).
is_string(Value) ->
is_list(Value) orelse is_binary(Value).

View File

@ -31,6 +31,7 @@
ensure_ssl_files/2,
ensure_ssl_files/3,
drop_invalid_certs/1,
ssl_file_conf_keypaths/0,
pem_dir/1,
is_managed_ssl_file/1,
is_valid_pem_file/1,
@ -371,6 +372,10 @@ is_valid_string(Binary) when is_binary(Binary) ->
_Otherwise -> false
end.
-spec ssl_file_conf_keypaths() -> [_ConfKeypath :: [binary()]].
ssl_file_conf_keypaths() ->
?SSL_FILE_OPT_PATHS.
%% Check if it is a valid PEM formatted key.
is_pem(MaybePem) ->
try