Skip to content

Commit

Permalink
Send SNI for erlang >= 17 (#455)
Browse files Browse the repository at this point in the history
* send sni for erlang >= 17

* Fix bad regex
  • Loading branch information
dspencer001 authored and benoitc committed Nov 7, 2017
1 parent 5b51fb8 commit 6ef0f9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion rebar.config
Expand Up @@ -3,7 +3,8 @@

{erl_opts, [debug_info,
{platform_define, "R14", no_callback_support},
{platform_define, "^[0-9]+", namespaced_types}
{platform_define, "^[0-9]+", namespaced_types},
{platform_define, "^R", no_proxy_sni_support}
]}.

{xref_checks, [undefined_function_calls]}.
Expand Down
14 changes: 13 additions & 1 deletion src/hackney_http_connect.erl
Expand Up @@ -24,6 +24,18 @@
-type http_socket() :: {atom(), inet:socket()}.
-export_type([http_socket/0]).

-ifdef(no_proxy_sni_support).

ssl_opts(Host, Opts) ->
hackney_connect:ssl_opts(Host, Opts).

-else.

ssl_opts(Host, Opts) ->
[{server_name_indication, Host} | hackney_connect:ssl_opts(Host,Opts)].

-endif.

%% @doc Atoms used to identify messages in {active, once | true} mode.
messages({hackney_ssl, _}) ->
{ssl, ssl_closed, ssl_error};
Expand Down Expand Up @@ -59,7 +71,7 @@ connect(ProxyHost, ProxyPort, Opts, Timeout)
%% upgrade the connection socket to handle SSL.
case Transport of
hackney_ssl ->
SSLOpts = hackney_connect:ssl_opts(Host, Opts),
SSLOpts = ssl_opts(Host, Opts),
%% upgrade the tcp connection
case ssl:connect(Socket, SSLOpts) of
{ok, SslSocket} ->
Expand Down

0 comments on commit 6ef0f9b

Please sign in to comment.