aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ranch.erl10
-rw-r--r--src/ranch_ssl.erl1
2 files changed, 10 insertions, 1 deletions
diff --git a/src/ranch.erl b/src/ranch.erl
index d2cd74b..32a0be6 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -48,6 +48,8 @@ start_listener(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts)
when is_integer(NbAcceptors) andalso is_atom(Transport)
andalso is_atom(Protocol) ->
_ = code:ensure_loaded(Transport),
+ %% @todo Remove in Ranch 2.0 and simply require ssl.
+ _ = ensure_ssl(Transport),
case erlang:function_exported(Transport, name, 0) of
false ->
{error, badarg};
@@ -90,10 +92,18 @@ stop_listener(Ref) ->
child_spec(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts)
when is_integer(NbAcceptors) andalso is_atom(Transport)
andalso is_atom(Protocol) ->
+ %% @todo Remove in Ranch 2.0 and simply require ssl.
+ _ = ensure_ssl(Transport),
{{ranch_listener_sup, Ref}, {ranch_listener_sup, start_link, [
Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts
]}, permanent, infinity, supervisor, [ranch_listener_sup]}.
+%% @todo Remove in Ranch 2.0 and simply require ssl.
+ensure_ssl(ranch_ssl) ->
+ require([crypto, asn1, public_key, ssl]);
+ensure_ssl(_) ->
+ ok.
+
-spec accept_ack(ref()) -> ok.
accept_ack(Ref) ->
receive {shoot, Ref, Transport, Socket, AckTimeout} ->
diff --git a/src/ranch_ssl.erl b/src/ranch_ssl.erl
index 5e8e68a..e9bbff2 100644
--- a/src/ranch_ssl.erl
+++ b/src/ranch_ssl.erl
@@ -85,7 +85,6 @@ messages() -> {ssl, ssl_closed, ssl_error}.
-spec listen(opts()) -> {ok, ssl:sslsocket()} | {error, atom()}.
listen(Opts) ->
- ranch:require([crypto, asn1, public_key, ssl]),
true = lists:keymember(cert, 1, Opts)
orelse lists:keymember(certfile, 1, Opts),
Opts2 = ranch:set_option_default(Opts, backlog, 1024),