From 2bed3437aee3f9519cdffa75e13cd8dd3306f954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Sun, 1 Jun 2014 01:26:21 +0200 Subject: ssl: parse SNI in received client hello records --- lib/ssl/src/ssl_handshake.erl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/ssl/src/ssl_handshake.erl') diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl index fc67d2c28d..b018332df1 100644 --- a/lib/ssl/src/ssl_handshake.erl +++ b/lib/ssl/src/ssl_handshake.erl @@ -1719,6 +1719,11 @@ dec_hello_extensions(<>, Acc) -> + <> = ExtData, + dec_hello_extensions(Rest, Acc#hello_extensions{sni = dec_sni(NameList)}); %% Ignore data following the ClientHello (i.e., %% extensions) if not understood. @@ -1731,6 +1736,13 @@ dec_hello_extensions(_, Acc) -> dec_hashsign(<>) -> {ssl_cipher:hash_algorithm(HashAlgo), ssl_cipher:sign_algorithm(SignAlgo)}. +%% Ignore unknown names (only host_name is supported) +dec_sni(<>) -> + #sni{hostname = binary_to_list(HostName)}; +dec_sni(<>) -> dec_sni(Rest); +dec_sni(_) -> undefined. + decode_next_protocols({next_protocol_negotiation, Protocols}) -> decode_next_protocols(Protocols, []). decode_next_protocols(<<>>, Acc) -> -- cgit v1.2.3