|
@@ -322,7 +322,8 @@ delete_old_file(_New, Old) ->
|
|
|
case is_generated_file(Old) andalso filelib:is_regular(Old) andalso file:delete(Old) of
|
|
case is_generated_file(Old) andalso filelib:is_regular(Old) andalso file:delete(Old) of
|
|
|
ok ->
|
|
ok ->
|
|
|
ok;
|
|
ok;
|
|
|
- false -> %% the file is not generated by us, or it is already deleted
|
|
|
|
|
|
|
+ %% the file is not generated by us, or it is already deleted
|
|
|
|
|
+ false ->
|
|
|
ok;
|
|
ok;
|
|
|
{error, Reason} ->
|
|
{error, Reason} ->
|
|
|
?SLOG(error, #{msg => "failed_to_delete_ssl_file", file_path => Old, reason => Reason})
|
|
?SLOG(error, #{msg => "failed_to_delete_ssl_file", file_path => Old, reason => Reason})
|
|
@@ -412,16 +413,21 @@ pem_dir(Dir) ->
|
|
|
filename:join([emqx:mutable_certs_dir(), Dir]).
|
|
filename:join([emqx:mutable_certs_dir(), Dir]).
|
|
|
|
|
|
|
|
is_hex_str(HexStr) ->
|
|
is_hex_str(HexStr) ->
|
|
|
- try is_hex_str2(ensure_str(HexStr))
|
|
|
|
|
- catch throw: not_hex -> false
|
|
|
|
|
|
|
+ try
|
|
|
|
|
+ is_hex_str2(ensure_str(HexStr))
|
|
|
|
|
+ catch
|
|
|
|
|
+ throw:not_hex -> false
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
is_hex_str2(HexStr) ->
|
|
is_hex_str2(HexStr) ->
|
|
|
- _ = [case S of
|
|
|
|
|
|
|
+ _ = [
|
|
|
|
|
+ case S of
|
|
|
S when S >= $0, S =< $9 -> S;
|
|
S when S >= $0, S =< $9 -> S;
|
|
|
S when S >= $a, S =< $f -> S;
|
|
S when S >= $a, S =< $f -> S;
|
|
|
_ -> throw(not_hex)
|
|
_ -> throw(not_hex)
|
|
|
- end || S <- HexStr],
|
|
|
|
|
|
|
+ end
|
|
|
|
|
+ || S <- HexStr
|
|
|
|
|
+ ],
|
|
|
true.
|
|
true.
|
|
|
|
|
|
|
|
hex_str(Bin) ->
|
|
hex_str(Bin) ->
|
|
@@ -457,8 +463,7 @@ do_drop_invalid_certs([Key | Keys], SSL) ->
|
|
|
PemOrPath ->
|
|
PemOrPath ->
|
|
|
case is_pem(PemOrPath) orelse is_valid_pem_file(PemOrPath) of
|
|
case is_pem(PemOrPath) orelse is_valid_pem_file(PemOrPath) of
|
|
|
true -> do_drop_invalid_certs(Keys, SSL);
|
|
true -> do_drop_invalid_certs(Keys, SSL);
|
|
|
- {error, _} ->
|
|
|
|
|
- do_drop_invalid_certs(Keys, maps:without([Key], SSL))
|
|
|
|
|
|
|
+ {error, _} -> do_drop_invalid_certs(Keys, maps:without([Key], SSL))
|
|
|
end
|
|
end
|
|
|
end.
|
|
end.
|
|
|
|
|
|