Skip to content

Commit

Permalink
Fix add option to specify SSL protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjtv committed May 20, 2016
1 parent 6ddb1c3 commit 116ef65
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/ts_profile.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

% protocol options
-record(proto_opts,
{ssl_ciphers = negociate, % for ssl only
{ssl_ciphers = negotiate, % for ssl only
bosh_path = "/http-bind/", % for bash only
tcp_reuseaddr = false, % for tcp reuseaddr
ip_transparent = false, % set IP_TRANSPARENT option on the socket
Expand Down
14 changes: 9 additions & 5 deletions src/tsung/ts_ssl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
-include("ts_config.hrl").


protocol_options(#proto_opts{ssl_ciphers=Ciphers, certificate = Cert,
protocol_options(#proto_opts{ssl_versions=Versions, ssl_ciphers=Ciphers, certificate = Cert,
is_first_connect = First, reuse_sessions =Reuse}) when First or not Reuse->
[binary, {active, once}, {reuse_sessions, false} ] ++ Cert ++ set_ciphers(Ciphers);
protocol_options(#proto_opts{ssl_ciphers=Ciphers, certificate = Cert}) ->
[binary, {active, once}] ++ Cert ++ set_ciphers(Ciphers).
[binary, {active, once}, {reuse_sessions, false} ] ++ Cert ++ set_ciphers(Ciphers) ++ set_versions(Versions);
protocol_options(#proto_opts{ssl_versions=Versions, ssl_ciphers=Ciphers, certificate = Cert}) ->
[binary, {active, once}] ++ Cert ++ set_ciphers(Ciphers) ++ set_versions(Versions).

set_ciphers(negociate)-> [];
set_ciphers(negotiate)-> [];
set_ciphers(Ciphers) -> [{ciphers, Ciphers}].

set_versions(negotiate)-> [];
set_versions(Versions) -> [{versions, Versions}].


%% -> {ok, Socket}
connect(Host, Port, Opts) when is_list(Host) ->
connect(Host, Port, opts_to_tcp_opts(Opts), infinity);
Expand Down
3 changes: 2 additions & 1 deletion src/tsung/tsung.app.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
{http_modified_since_date, "Fri, 14 Nov 2003 02:43:31 GMT"},
{client_retry_timeout, 10}, % retry sending (in microsec.)
{max_retries, 3}, % number of max retries
{ssl_ciphers, negociate},
{ssl_ciphers, negotiate},
{ssl_versions, negotiate},

%%% -------- JABBER OPTIONS
{jabber_users, 2000000},
Expand Down
8 changes: 7 additions & 1 deletion src/tsung_controller/ts_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,17 @@ parse(Element = #xmlElement{name=option, attributes=Attrs},
ets:insert(Tab,{{thinktime, override}, Override}),
lists:foldl( fun parse/2, Conf, Element#xmlElement.content);
"ssl_ciphers" ->
Cipher = getAttr(string,Attrs, value, negociate),
Cipher = getAttr(string,Attrs, value, negotiate),
OldProto = Conf#config.proto_opts,
NewProto = OldProto#proto_opts{ssl_ciphers=Cipher},
lists:foldl( fun parse/2, Conf#config{proto_opts=NewProto},
Element#xmlElement.content);
"ssl_versions" ->
Protocol = getAttr(atom,Attrs, value, negotiate),
OldProto = Conf#config.proto_opts,
NewProto = OldProto#proto_opts{ssl_versions=[Protocol]},
lists:foldl( fun parse/2, Conf#config{proto_opts=NewProto},
Element#xmlElement.content);
"ssl_reuse_sessions" ->
case getAttr(atom,Attrs, value, true) of
false ->
Expand Down

0 comments on commit 116ef65

Please sign in to comment.