Fix SSL handshake when SNI-extension is empty.

While I'm here:

- Reduce diff with the main Erlang port
- Do not mute install commands

PR:		194214
Submitted by:	Dave Cottlehuber
This commit is contained in:
Jimmy Olgeni 2014-10-09 12:48:31 +00:00
parent a79a58bde1
commit 38bdb52017
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=370520
3 changed files with 49 additions and 4 deletions

View File

@ -3,6 +3,7 @@
PORTNAME= erlang
PORTVERSION= 17.3
PORTREVISION= 1
CATEGORIES= lang parallel java
MASTER_SITES= http://www.erlang.org/download/:erlangorg \
http://erlang.stacken.kth.se/download/:erlangorg \
@ -37,7 +38,7 @@ SCTP_DESC= Enable SCTP support
SMP_DESC= Enable SMP support
WX_DESC= Enable WX application
GS_DESC= Enable GS application (deprecated)
DTRACE_DESC= Enable DTrace support (experimental)
DTRACE_DESC= Enable DTrace support
OPTIONS_DEFAULT=SMP OPENSSL THREADS SCTP KQUEUE
@ -62,9 +63,11 @@ DISTFILES+= ${ERLANG_DOCS}:erlangorg
# probes fixed does not match the number of defined probes (54 != 132,
# respectively)" you probably misconfigured DTrace in some way.
.if ${OSVERSION} < 1000000
.if ${ARCH} == "amd64" && ${PORT_OPTIONS:MDTRACE} && ! ${PORT_OPTIONS:MGCC}
IGNORE= DTRACE support on amd64 requires GCC option
.endif
.endif
.if ${PORT_OPTIONS:MGCC}
USE_GCC?= yes
@ -165,12 +168,12 @@ post-install:
-C ${STAGEDIR}${PREFIX}/lib/${ERLANG_LIB} \
"man/man$${SECTION}/*.$${SECTION}" || ${TRUE}; \
done
@${RM} -rf ${STAGEDIR}${PREFIX}/lib/${ERLANG_LIB}/man/cat?
${RM} -rf ${STAGEDIR}${PREFIX}/lib/${ERLANG_LIB}/man/cat?
.if ${PORT_OPTIONS:MDOCS}
@${TAR} --unlink -xzpf ${DISTDIR}/${DIST_SUBDIR}/${ERLANG_DOCS} \
${TAR} --unlink -xzpf ${DISTDIR}/${DIST_SUBDIR}/${ERLANG_DOCS} \
-C ${STAGEDIR}${PREFIX}/lib/${ERLANG_LIB}
@${INSTALL_DATA} ${WRKSRC}/lib/dialyzer/doc/*.txt \
${INSTALL_DATA} ${WRKSRC}/lib/dialyzer/doc/*.txt \
${STAGEDIR}${PREFIX}/lib/${ERLANG_LIB}/lib/dialyzer-*/doc/
.endif

View File

@ -0,0 +1,15 @@
$FreeBSD$
--- lib/ssl/src/ssl_handshake.erl.orig
+++ lib/ssl/src/ssl_handshake.erl
@@ -1732,6 +1732,9 @@
#ec_point_formats{ec_point_format_list =
ECPointFormats}});
+dec_hello_extensions(<<?UINT16(?SNI_EXT), ?UINT16(Len), Rest/binary>>, Acc) when Len == 0 ->
+ dec_hello_extensions(Rest, Acc#hello_extensions{sni = ""}); %% Server may send an empy SNI
+
dec_hello_extensions(<<?UINT16(?SNI_EXT), ?UINT16(Len),
ExtData:Len/binary, Rest/binary>>, Acc) ->
<<?UINT16(_), NameList/binary>> = ExtData,

View File

@ -0,0 +1,27 @@
$FreeBSD$
--- lib/ssl/test/ssl_handshake_SUITE.erl.orig
+++ lib/ssl/test/ssl_handshake_SUITE.erl
@@ -39,6 +39,7 @@
decode_unknown_hello_extension_correctly,
encode_single_hello_sni_extension_correctly,
decode_single_hello_sni_extension_correctly,
+ decode_empty_server_sni_correctly,
select_proper_tls_1_2_rsa_default_hashsign].
%%--------------------------------------------------------------------
@@ -106,6 +107,13 @@
Decoded = ssl_handshake:decode_hello_extensions(SNI),
Exts = Decoded.
+decode_empty_server_sni_correctly(_Config) ->
+ Exts = #hello_extensions{sni = ""},
+ SNI = <<?UINT16(?SNI_EXT),?UINT16(0)>>,
+ Decoded = ssl_handshake:decode_hello_extensions(SNI),
+ Exts = Decoded.
+
+
select_proper_tls_1_2_rsa_default_hashsign(_Config) ->
% RFC 5246 section 7.4.1.4.1 tells to use {sha1,rsa} as default signature_algorithm for RSA key exchanges
{sha, rsa} = ssl_handshake:select_hashsign_algs(undefined, ?rsaEncryption, {3,3}),