[erlang-bugs] Type errors in ssl application since OTP 17.0-rc2
Johannes Weißl
jargon@REDACTED
Sun Mar 2 22:42:00 CET 2014
Hello,
we noticed dialyzer warnings in our application with OTP 17.0-rc2.
Through "git bisect" I could determine the commit which made the error
apparent:
48c3778 Ingela Anderton Andin Fri Feb 14 17:08:14 2014 +0100
ssl: Fix possible mismatch between SSL/TLS version and default ciphers
I attached a small example (ssl_bug.erl), it can be compiled and run
like this:
erlc ssl_bug.erl
erl -noshell -s ssl_bug listen no_use_ssl -s init stop
erl -noshell -s ssl_bug listen use_ssl -s init stop
Although the program seems correct, dialyzer throws a warning:
dialyzer --build_plt --apps erts kernel stdlib mnesia compiler asn1 \
syntax_tools hipe crypto public_key ssl
dialyzer ssl_bug.erl
ssl_bug.erl:30: The call ssl:sockname(Socket::port()) will never return since the success typing is ({'sslsocket',_,pid() | {port(),{'config',_,_,_,_,{_,_,_,_},_}}}) -> any() and the contract is (#sslsocket{}) -> {'ok',{inet:ip_address(),inet:port_number()}} | {'error',reason()}
There are multiple type issues in the ssl application, which could be
responsible for this, e.g.:
dtls_handshake.erl:57: The call dtls_record:highest_protocol_version(Versions::'undefined' | ['dtlsv1' | 'dtlsv1.2' | 'sslv3' | 'tlsv1' | 'tlsv1.1' | 'tlsv1.2']) will never return since the success typing is ([any(),...]) -> any() and the contract is ([tls_version()]) -> tls_version()
(tls_version() is {integer(), integer()})
Regards,
Johannes Weißl
-------------- next part --------------
-module(ssl_bug).
-export([listen/1]).
listen(Args) ->
UseSsl = proplists:get_bool(use_ssl, Args),
io:format("Use SSL: ~p~n", [UseSsl]),
case gen_tcp_or_ssl_listen(0, [], UseSsl) of
{ok,ListenSocket} ->
{ok,{Address,Port}} = inet_or_ssl_sockname(ListenSocket, UseSsl),
io:format("Listening on ~p port ~p~n", [Address, Port]),
{ok,ListenSocket};
{error,Reason} ->
io:format("Error, reason: ~p~n", [Reason]),
{error,Reason}
end.
gen_tcp_or_ssl_listen(Port, Options, false) ->
gen_tcp:listen(Port, Options);
gen_tcp_or_ssl_listen(Port, Options, true) ->
DefaultOptions = [{ciphers,ssl:cipher_suites()}],
case ssl:start() of
ok -> ssl:listen(Port, Options ++ DefaultOptions);
Error={error,_} -> Error
end.
inet_or_ssl_sockname(Socket, false) ->
inet:sockname(Socket);
inet_or_ssl_sockname(Socket, true) ->
ssl:sockname(Socket).
More information about the erlang-bugs
mailing list