mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 12:40:25 +00:00
Merge branch 'ssl-password-cacert' of https://github.com/DeadZen/cowboy
This commit is contained in:
commit
811d11a1a2
1 changed files with 13 additions and 4 deletions
|
@ -68,21 +68,30 @@ listen(Opts) ->
|
||||||
{port, Port} = lists:keyfind(port, 1, Opts),
|
{port, Port} = lists:keyfind(port, 1, Opts),
|
||||||
Backlog = proplists:get_value(backlog, Opts, 1024),
|
Backlog = proplists:get_value(backlog, Opts, 1024),
|
||||||
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
|
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
|
||||||
{keyfile, KeyFile} = lists:keyfind(keyfile, 1, Opts),
|
KeyFileOpts =
|
||||||
{password, Password} = lists:keyfind(password, 1, Opts),
|
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},
|
ListenOpts0 = [binary, {active, false},
|
||||||
{backlog, Backlog}, {packet, raw}, {reuseaddr, true},
|
{backlog, Backlog}, {packet, raw}, {reuseaddr, true},
|
||||||
{certfile, CertFile}, {keyfile, KeyFile}, {password, Password}],
|
{certfile, CertFile}],
|
||||||
ListenOpts1 =
|
ListenOpts1 =
|
||||||
case lists:keyfind(ip, 1, Opts) of
|
case lists:keyfind(ip, 1, Opts) of
|
||||||
false -> ListenOpts0;
|
false -> ListenOpts0;
|
||||||
Ip -> [Ip|ListenOpts0]
|
Ip -> [Ip|ListenOpts0]
|
||||||
end,
|
end,
|
||||||
ListenOpts =
|
ListenOpts2 =
|
||||||
case lists:keyfind(cacertfile, 1, Opts) of
|
case lists:keyfind(cacertfile, 1, Opts) of
|
||||||
false -> ListenOpts1;
|
false -> ListenOpts1;
|
||||||
CACertFile -> [CACertFile|ListenOpts1]
|
CACertFile -> [CACertFile|ListenOpts1]
|
||||||
end,
|
end,
|
||||||
|
ListenOpts = ListenOpts2 ++ KeyFileOpts ++ PasswordOpts,
|
||||||
ssl:listen(Port, ListenOpts).
|
ssl:listen(Port, ListenOpts).
|
||||||
|
|
||||||
%% @doc Accept an incoming connection on a listen socket.
|
%% @doc Accept an incoming connection on a listen socket.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue