From df823bf39b54b7057adc48e6d44123d0fcd486f0 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 29 Mar 2022 18:57:54 +0200 Subject: [PATCH] ssl_client.c: Re-order partially extension writing Signed-off-by: Ronald Cron --- library/ssl_client.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/library/ssl_client.c b/library/ssl_client.c index fd9686550..769a8f293 100644 --- a/library/ssl_client.c +++ b/library/ssl_client.c @@ -411,12 +411,13 @@ static int ssl_write_client_hello_body( mbedtls_ssl_context *ssl, p_extensions_len = p; p += 2; -#if defined(MBEDTLS_SSL_PROTO_TLS1_3) - ret = mbedtls_ssl_tls13_write_client_hello_exts( ssl, p, end, &output_len ); +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + /* Write server name extension */ + ret = mbedtls_ssl_write_hostname_ext( ssl, p, end, &output_len ); if( ret != 0 ) return( ret ); p += output_len; -#endif +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ #if defined(MBEDTLS_SSL_ALPN) ret = ssl_write_alpn_ext( ssl, p, end, &output_len ); @@ -425,6 +426,13 @@ static int ssl_write_client_hello_body( mbedtls_ssl_context *ssl, p += output_len; #endif /* MBEDTLS_SSL_ALPN */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3) + ret = mbedtls_ssl_tls13_write_client_hello_exts( ssl, p, end, &output_len ); + if( ret != 0 ) + return( ret ); + p += output_len; +#endif + #if defined(MBEDTLS_SSL_PROTO_TLS1_3) #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) if( mbedtls_ssl_conf_tls13_some_ephemeral_enabled( ssl ) ) @@ -445,14 +453,6 @@ static int ssl_write_client_hello_body( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3 */ -#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) - /* Write server name extension */ - ret = mbedtls_ssl_write_hostname_ext( ssl, p, end, &output_len ); - if( ret != 0 ) - return( ret ); - p += output_len; -#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ - /* Add more extensions here */ /* Write the length of the list of extensions. */