Skip to content

Commit

Permalink
Fix IDNA support
Browse files Browse the repository at this point in the history
  • Loading branch information
zinid committed Sep 22, 2019
1 parent 984b3c3 commit 3e892bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/xmpp_stream_out.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1126,11 +1126,10 @@ idna_to_ascii(<<$[, _/binary>> = Host) ->
false
end;
idna_to_ascii(Host) ->
SHost = binary_to_list(Host),
case inet:parse_address(SHost) of
case inet:parse_address(binary_to_list(Host)) of
{ok, _} -> Host;
{error, _} ->
try idna:to_ascii(SHost)
try idna:utf8_to_ascii(Host)
catch _:_ -> false
end
end.
Expand Down
5 changes: 2 additions & 3 deletions src/xmpp_stream_pkix.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ get_cert_domains(Cert) ->
verify_server_cert(Server, Socket) ->
case verify_cert(Socket) of
{ok, Cert} ->
try iolist_to_binary(idna:to_ascii(Server)) of
try list_to_binary(idna:utf8_to_ascii(Server)) of
AsciiServer ->
case lists:any(
fun(D) -> match_domain(AsciiServer, D) end,
Expand Down Expand Up @@ -166,8 +166,7 @@ get_domains_from_san(Extensions) when is_list(Extensions) ->
{ok, #jid{luser = <<"">>,
lresource = <<"">>,
lserver = Domain}} ->
try iolist_to_binary(
idna:to_ascii(binary_to_list(Domain)))
try list_to_binary(idna:utf8_to_ascii(Domain))
catch _:_ -> []
end;
_ ->
Expand Down

0 comments on commit 3e892bc

Please sign in to comment.