chore(ocsp): catch unexpected error when fetching ocsp response

This commit is contained in:
Thales Macedo Garitezi 2023-03-16 09:55:52 -03:00
parent d1f58d6e2d
commit a614bdc94a
2 changed files with 29 additions and 1 deletions

View File

@ -300,7 +300,17 @@ with_refresh_params(ListenerID, Conf, ErrorRet, Fn) ->
error ->
ErrorRet;
{ok, Params} ->
Fn(Params)
try
Fn(Params)
catch
Kind:Error ->
?SLOG(error, #{
msg => "error_fetching_ocsp_response",
listener_id => ListenerID,
error => {Kind, Error}
}),
ErrorRet
end
end.
get_refresh_params(ListenerID, undefined = _Conf) ->

View File

@ -912,6 +912,24 @@ do_t_validations(_Config) ->
ok.
t_unknown_error_fetching_ocsp_response(_Config) ->
ListenerID = <<"ssl:test_ocsp">>,
TestPid = self(),
ok = meck:expect(
emqx_ocsp_cache,
http_get,
fun(_RequestURI, _HTTPTimeout) ->
TestPid ! error_raised,
meck:exception(error, something_went_wrong)
end
),
?assertEqual(error, emqx_ocsp_cache:fetch_response(ListenerID)),
receive
error_raised -> ok
after 200 -> ct:fail("should have tried to fetch ocsp response")
end,
ok.
t_openssl_client(Config) ->
TLSVsn = ?config(tls_vsn, Config),
WithStatusRequest = ?config(status_request, Config),