Skip to content

Commit

Permalink
Merge branch 'ssl-password-cacert' of https://github.com/DeadZen/cowboy
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Hoguin committed Feb 20, 2012
2 parents 9baf3e2 + e67d839 commit 811d11a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/cowboy_ssl_transport.erl
Expand Up @@ -68,21 +68,30 @@ listen(Opts) ->
{port, Port} = lists:keyfind(port, 1, Opts),
Backlog = proplists:get_value(backlog, Opts, 1024),
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
{keyfile, KeyFile} = lists:keyfind(keyfile, 1, Opts),
{password, Password} = lists:keyfind(password, 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}, {keyfile, KeyFile}, {password, Password}],
{certfile, CertFile}],
ListenOpts1 =
case lists:keyfind(ip, 1, Opts) of
false -> ListenOpts0;
Ip -> [Ip|ListenOpts0]
end,
ListenOpts =
ListenOpts2 =
case lists:keyfind(cacertfile, 1, Opts) of
false -> ListenOpts1;
CACertFile -> [CACertFile|ListenOpts1]
end,
ListenOpts = ListenOpts2 ++ KeyFileOpts ++ PasswordOpts,
ssl:listen(Port, ListenOpts).

%% @doc Accept an incoming connection on a listen socket.
Expand Down

0 comments on commit 811d11a

Please sign in to comment.