diff options
author | András Veres-Szentkirályi <[email protected]> | 2014-06-01 01:26:21 +0200 |
---|---|---|
committer | András Veres-Szentkirályi <[email protected]> | 2014-06-01 01:26:21 +0200 |
commit | 2bed3437aee3f9519cdffa75e13cd8dd3306f954 (patch) | |
tree | 16f81210ff975fa1e7020c458554e7412f92fbc7 /lib/ssl/src/ssl_handshake.erl | |
parent | 6b6cd01b607a1bfcf61bb6d5f4cc3fe9b37445db (diff) | |
download | otp-2bed3437aee3f9519cdffa75e13cd8dd3306f954.tar.gz otp-2bed3437aee3f9519cdffa75e13cd8dd3306f954.tar.bz2 otp-2bed3437aee3f9519cdffa75e13cd8dd3306f954.zip |
ssl: parse SNI in received client hello records
Diffstat (limited to 'lib/ssl/src/ssl_handshake.erl')
-rw-r--r-- | lib/ssl/src/ssl_handshake.erl | 12 |
1 files changed, 12 insertions, 0 deletions
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(<<?UINT16(?EC_POINT_FORMATS_EXT), ?UINT16(Len), dec_hello_extensions(Rest, Acc#hello_extensions{ec_point_formats = #ec_point_formats{ec_point_format_list = ECPointFormats}}); + +dec_hello_extensions(<<?UINT16(?SNI_EXT), ?UINT16(Len), + ExtData:Len/binary, Rest/binary>>, Acc) -> + <<?UINT16(_), NameList/binary>> = 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(<<?BYTE(HashAlgo), ?BYTE(SignAlgo)>>) -> {ssl_cipher:hash_algorithm(HashAlgo), ssl_cipher:sign_algorithm(SignAlgo)}. +%% Ignore unknown names (only host_name is supported) +dec_sni(<<?BYTE(?SNI_NAMETYPE_HOST_NAME), ?UINT16(Len), + HostName:Len/binary, _/binary>>) -> + #sni{hostname = binary_to_list(HostName)}; +dec_sni(<<?BYTE(_), ?UINT16(Len), _:Len, Rest/binary>>) -> dec_sni(Rest); +dec_sni(_) -> undefined. + decode_next_protocols({next_protocol_negotiation, Protocols}) -> decode_next_protocols(Protocols, []). decode_next_protocols(<<>>, Acc) -> |