Skip to content

Commit

Permalink
Use correct httpc SSL options (requires OTP 25.1+)
Browse files Browse the repository at this point in the history
This also removes the `ssl` application environment which didn't seem to
be used anymore.
  • Loading branch information
eproxus authored and kivra-adalin committed Sep 7, 2023
1 parent e88cafe commit 3ab4749
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ raven-erlang
raven-erlang is an Erlang client for [Sentry](http://aboutsentry.com/) that integrates with the
standard ```error_logger``` module.


Requirements
============

* Erlang 25.1 or higher

Quick Start
===========

Expand Down
9 changes: 4 additions & 5 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 noet syntax=erlang
{erl_opts, [ warnings_as_errors,
warn_export_all,
{platform_define, "^R14", no_callbacks}
]
}.
{erl_opts, [
warnings_as_errors,
warn_export_all
]}.

{deps, [jsx]}.

Expand Down
15 changes: 6 additions & 9 deletions src/raven_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ stop() ->

%% @hidden
start(_StartType, _StartArgs) ->
case application:get_env(ssl) of
{ok, Options} ->
persistent_term:put(?RAVEN_SSL_PERSIST_KEY, {ssl, Options});
_ ->
logger:notice("Raven not configured with httpc ssl options"),
persistent_term:put(?RAVEN_SSL_PERSIST_KEY, {ssl, []})
end,
persistent_term:put(
?RAVEN_SSL_PERSIST_KEY,
{ssl, httpc:ssl_verify_host_options(true)}
),
{ok, _ProfilePid} = inets:start(httpc, [{profile, ?RAVEN_HTTPC_PROFILE}]),
case {application:get_env(uri), application:get_env(dsn)} of
{undefined, undefined} ->
Expand Down Expand Up @@ -69,8 +66,8 @@ stop(_State) ->
_ ->
ok
end,
inets:stop(httpc, ?RAVEN_HTTPC_PROFILE),
ok.
ok = inets:stop(httpc, ?RAVEN_HTTPC_PROFILE),
true = persistent_term:erase(?RAVEN_SSL_PERSIST_KEY).

%% @private
ensure_started(App) ->
Expand Down
10 changes: 4 additions & 6 deletions src/raven_logger_backend.erl
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,12 @@ logger_backend_test_() ->

test_setup() ->
error_logger:tty(false),
persistent_term:put(?RAVEN_SSL_PERSIST_KEY, {ssl, []}),
meck:new(raven_send_sentry_safe),
meck:new(httpc),
meck:new(raven_send_sentry_safe, [passthrough]),
meck:new(httpc, [passthrough]),
meck:expect(raven_send_sentry_safe, capture, 2, fun mock_capture/2),
meck:expect(httpc, set_options, 1, fun(_) -> ok end),
meck:expect(httpc, request, 5, fun mock_request/5),
application:start(raven), %% To se key vsn
ok = application:start(raven),
application:set_env(raven, ipfamily, dummy),
application:set_env(raven, uri, "http://foo"),
application:set_env(raven, public_key, <<"hello">>),
Expand All @@ -180,8 +179,7 @@ test_teardown(_) ->
application:unset_env(raven, public_key),
application:unset_env(raven, private_key),
application:unset_env(raven, project),
application:stop(raven),
persistent_term:erase(?RAVEN_SSL_PERSIST_KEY),
ok = application:stop(raven),
error_logger:tty(true),
ok.

Expand Down

0 comments on commit 3ab4749

Please sign in to comment.