chore(tls): guard empty pem/path string
This commit is contained in:
parent
5698b9cfeb
commit
5bfb9367ea
|
@ -368,6 +368,7 @@ do_ensure_ssl_file(Dir, Key, SSL, MaybePem, DryRun) ->
|
|||
end
|
||||
end.
|
||||
|
||||
is_valid_string(Empty) when Empty == <<>>; Empty == "" -> false;
|
||||
is_valid_string(String) when is_list(String) ->
|
||||
io_lib:printable_unicode_list(String);
|
||||
is_valid_string(Binary) when is_binary(Binary) ->
|
||||
|
|
|
@ -104,6 +104,17 @@ ssl_files_failure_test_() ->
|
|||
)
|
||||
end},
|
||||
{"bad_pem_string", fun() ->
|
||||
%% empty string
|
||||
?assertMatch(
|
||||
{error, #{
|
||||
reason := invalid_file_path_or_pem_string, which_options := [<<"keyfile">>]
|
||||
}},
|
||||
emqx_tls_lib:ensure_ssl_files("/tmp", #{
|
||||
<<"keyfile">> => <<>>,
|
||||
<<"certfile">> => bin(test_key()),
|
||||
<<"cacertfile">> => bin(test_key())
|
||||
})
|
||||
),
|
||||
%% not valid unicode
|
||||
?assertMatch(
|
||||
{error, #{
|
||||
|
|
Loading…
Reference in New Issue