diff options
Diffstat (limited to 'src/gun.erl')
-rw-r--r-- | src/gun.erl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/gun.erl b/src/gun.erl index 3ca65b7..42bd409 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -1104,10 +1104,15 @@ ensure_alpn_sni(Protocols0, TransOpts0, OriginHost) -> %% %% Normally only DNS hostnames are supported for SNI. However, the ssl %% application itself allows any string through so we do the same. - if - is_list(OriginHost) -> [{server_name_indication, OriginHost}|TransOpts]; - is_atom(OriginHost) -> [{server_name_indication, atom_to_list(OriginHost)}|TransOpts]; - true -> TransOpts + %% + %% Only add SNI if not already present and OriginHost isn't an IP address. + case lists:keymember(server_name_indication, 1, TransOpts) of + false when is_list(OriginHost) -> + [{server_name_indication, OriginHost}|TransOpts]; + false when is_atom(OriginHost) -> + [{server_name_indication, atom_to_list(OriginHost)}|TransOpts]; + _ -> + TransOpts end. %% Normal TLS handshake. |