Skip to content
Permalink
Browse files
Add a runtime SSL compatibility check for OTP 21 releases
  • Loading branch information
etrepum committed Jan 15, 2019
1 parent 9458608 commit 99cc81b91bd2785455c22d04877c543f09031585
Showing 2 changed files with 18 additions and 2 deletions.
@@ -5,7 +5,8 @@
{platform_define, "^(R14|R15|R16B|17)", 'rand_mod_unavailable'},
{platform_define, "^(R14|R15|R16B|17)", 'sni_unavailable'},
{platform_define, "^(R14|R15|R16)", 'map_unavailable'},
{platform_define, "^(R14|R15|R16|17|18|19|20)", 'ssl_handshake_unavailable'}]}.
{platform_define, "^(R14|R15|R16|17|18|19|20)", 'ssl_handshake_unavailable'},
{platform_define, "^21-", 'otp_21'}]}.
{cover_enabled, true}.
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
{dialyzer_opts, [{warnings, [no_return,
@@ -167,11 +167,26 @@ start_server(F, State=#mochiweb_socket_server{ssl=Ssl, name=Name}) ->
gen_server:F(Name, ?MODULE, State, [])
end.

-ifdef(otp_21).
check_ssl_compatibility() ->
case lists:keyfind(ssl, 1, application:loaded_applications()) of
{_, _, V} when V =:= "9.1" orelse V =:= "9.1.1" ->
{error, "ssl-" ++ V ++ " (OTP 21.2 to 21.2.2) has a regression and is not safe to use with mochiweb. See https://bugs.erlang.org/browse/ERL-830"};
_ ->
ok
end.
-else.
check_ssl_compatibility() ->
ok.
-endif.

prep_ssl(true) ->
ok = mochiweb:ensure_started(crypto),
ok = mochiweb:ensure_started(asn1),
ok = mochiweb:ensure_started(public_key),
ok = mochiweb:ensure_started(ssl);
ok = mochiweb:ensure_started(ssl),
ok = check_ssl_compatibility(),
ok;
prep_ssl(false) ->
ok.

0 comments on commit 99cc81b

Please sign in to comment.