aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeadZen <[email protected]>2012-02-08 15:14:02 -0500
committerDeadZen <[email protected]>2012-02-08 15:14:02 -0500
commite67d839154a0c031e667903da013a4a49be86ced (patch)
treeb242977a336c8e300d771c627326e24d1d2ca9dd
parente7b6e2a402922724ffd668161ed1b65533b5c034 (diff)
downloadcowboy-e67d839154a0c031e667903da013a4a49be86ced.tar.gz
cowboy-e67d839154a0c031e667903da013a4a49be86ced.tar.bz2
cowboy-e67d839154a0c031e667903da013a4a49be86ced.zip
Add CA support and make SSL certificate password optional
-rw-r--r--src/cowboy_ssl_transport.erl20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/cowboy_ssl_transport.erl b/src/cowboy_ssl_transport.erl
index bf8b1fb..b7d555b 100644
--- a/src/cowboy_ssl_transport.erl
+++ b/src/cowboy_ssl_transport.erl
@@ -68,21 +68,33 @@ 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.