@@ -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, #{