Skip to content

Commit

Permalink
avoid passing IP addresses to ssl:connect/3 as string
Browse files Browse the repository at this point in the history
failing to do so results in a cryptic error result
{options, {{server_name_indication, "127.0.0.1"}}}

See also (thanks to @ntalfer for pointing me in the right direction)
edgurgel/httpoison#164 (comment)
  • Loading branch information
dnet committed Sep 7, 2017
1 parent fae7678 commit d02c5a5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sslproxy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ ssl_connect_with_fallback(_, _, [], _, Error) -> Error;
ssl_connect_with_fallback(Host, Port, Versions, Fallback, _) ->
Options = [{verify, verify_none}, {packet, raw}, {active, true},
{mode, binary}, {versions, Versions}, {fallback, Fallback}],
case ssl:connect(Host, Port, Options) of
ConHost = case inet:parse_address(Host) of
{ok, IP} -> IP;
_ -> Host
end,
case ssl:connect(ConHost, Port, Options) of
{ok, _} = R -> R;
{error, _} = R -> ssl_connect_with_fallback(Host, Port, tl(Versions), true, R)
end.
Expand Down

0 comments on commit d02c5a5

Please sign in to comment.