diff --git a/src/cowboy_ssl_transport.erl b/src/cowboy_ssl_transport.erl
index ccd8e5a5..8074209d 100644
--- a/src/cowboy_ssl_transport.erl
+++ b/src/cowboy_ssl_transport.erl
@@ -48,13 +48,16 @@ messages() -> {ssl, ssl_closed, ssl_error}.
%% by default.
%%
certfileMandatory. Path to a file containing the user's
%% certificate.
-%% keyfileMandatory. Path to the file containing the user's
+%% keyfileOptional. Path to the file containing the user's
%% private PEM encoded key.
%% cacertfileOptional. Path to file containing PEM encoded
%% CA certificates (trusted certificates used for verifying a peer
%% certificate).
-%% passwordMandatory. String containing the user's password.
+%% passwordOptional. String containing the user's password.
%% All private keyfiles must be password protected currently.
+%% ciphersOptional. The cipher suites that should be supported.
+%% The function ssl:cipher_suites/0 can be used to find all available
+%% ciphers.
%%
%%
%% @see ssl:listen/2
@@ -67,30 +70,18 @@ listen(Opts) ->
{port, Port} = lists:keyfind(port, 1, Opts),
Backlog = proplists:get_value(backlog, Opts, 1024),
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
- KeyFileOpts =
- case lists:keyfind(keyfile, 1, Opts) of
- false -> [];
- KeyFile -> [KeyFile]
- end,
- PasswordOpts =
- case lists:keyfind(password, 1, Opts) of
- false -> [];
- Password -> [Password]
- end,
+
ListenOpts0 = [binary, {active, false},
{backlog, Backlog}, {packet, raw}, {reuseaddr, true},
{certfile, CertFile}],
- ListenOpts1 =
- case lists:keyfind(ip, 1, Opts) of
- false -> ListenOpts0;
- Ip -> [Ip|ListenOpts0]
- end,
- ListenOpts2 =
- case lists:keyfind(cacertfile, 1, Opts) of
- false -> ListenOpts1;
- CACertFile -> [CACertFile|ListenOpts1]
- end,
- ListenOpts = ListenOpts2 ++ KeyFileOpts ++ PasswordOpts,
+ ListenOpts = lists:foldl(fun
+ ({ip, _} = Ip, Acc) -> [Ip | Acc];
+ ({keyfile, _} = KeyFile, Acc) -> [KeyFile | Acc];
+ ({cacertfile, _} = CACertFile, Acc) -> [CACertFile | Acc];
+ ({password, _} = Password, Acc) -> [Password | Acc];
+ ({ciphers, _} = Ciphers, Acc) -> [Ciphers | Acc];
+ (_, Acc) -> Acc
+ end, ListenOpts0, Opts),
ssl:listen(Port, ListenOpts).
%% @doc Accept an incoming connection on a listen socket.