1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-07 06:42:56 +03:00

Ability to disable server_name extension (RFC 6066)

This commit is contained in:
Paul Bakker
2013-08-27 21:55:01 +02:00
parent d2f068e071
commit 0be444a8b1
8 changed files with 41 additions and 6 deletions

View File

@@ -51,6 +51,7 @@ typedef UINT32 uint32_t;
#include <time.h>
#endif
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
static void ssl_write_hostname_ext( ssl_context *ssl,
unsigned char *buf,
size_t *olen )
@@ -100,6 +101,7 @@ static void ssl_write_hostname_ext( ssl_context *ssl,
*olen = ssl->hostname_len + 9;
}
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
static void ssl_write_renegotiation_ext( ssl_context *ssl,
unsigned char *buf,
@@ -534,8 +536,10 @@ static int ssl_write_client_hello( ssl_context *ssl )
// First write extensions, then the total length
//
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
ssl_write_hostname_ext( ssl, p + 2 + ext_len, &olen );
ext_len += olen;
#endif
ssl_write_renegotiation_ext( ssl, p + 2 + ext_len, &olen );
ext_len += olen;

View File

@@ -336,6 +336,7 @@ static int ssl_parse_ticket( ssl_context *ssl,
}
#endif /* POLARSSL_SSL_SESSION_TICKETS */
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
static int ssl_parse_servername_ext( ssl_context *ssl,
const unsigned char *buf,
size_t len )
@@ -385,6 +386,7 @@ static int ssl_parse_servername_ext( ssl_context *ssl,
return( 0 );
}
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
static int ssl_parse_renegotiation_info( ssl_context *ssl,
const unsigned char *buf,
@@ -1157,6 +1159,7 @@ static int ssl_parse_client_hello( ssl_context *ssl )
}
switch( ext_id )
{
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
case TLS_EXT_SERVERNAME:
SSL_DEBUG_MSG( 3, ( "found ServerName extension" ) );
if( ssl->f_sni == NULL )
@@ -1166,6 +1169,7 @@ static int ssl_parse_client_hello( ssl_context *ssl )
if( ret != 0 )
return( ret );
break;
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
case TLS_EXT_RENEGOTIATION_INFO:
SSL_DEBUG_MSG( 3, ( "found renegotiation extension" ) );

View File

@@ -35,12 +35,12 @@
#if defined(POLARSSL_SSL_TLS_C)
#include "polarssl/aes.h"
#include "polarssl/debug.h"
#include "polarssl/ssl.h"
#include "polarssl/arc4.h"
#include "polarssl/camellia.h"
#include "polarssl/des.h"
#include "polarssl/debug.h"
#include "polarssl/ssl.h"
#if defined(POLARSSL_GCM_C)
#include "polarssl/gcm.h"
@@ -3053,8 +3053,10 @@ int ssl_init( ssl_context *ssl )
memset( ssl-> in_ctr, 0, SSL_BUFFER_LEN );
memset( ssl->out_ctr, 0, SSL_BUFFER_LEN );
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
ssl->hostname = NULL;
ssl->hostname_len = 0;
#endif
#if defined(POLARSSL_SSL_SESSION_TICKETS)
ssl->ticket_lifetime = SSL_DEFAULT_TICKET_LIFETIME;
@@ -3356,6 +3358,7 @@ int ssl_set_dh_param_ctx( ssl_context *ssl, dhm_context *dhm_ctx )
}
#endif /* POLARSSL_DHM_C */
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
int ssl_set_hostname( ssl_context *ssl, const char *hostname )
{
if( hostname == NULL )
@@ -3387,6 +3390,7 @@ void ssl_set_sni( ssl_context *ssl,
ssl->f_sni = f_sni;
ssl->p_sni = p_sni;
}
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
void ssl_set_max_version( ssl_context *ssl, int major, int minor )
{
@@ -3918,12 +3922,14 @@ void ssl_free( ssl_context *ssl )
polarssl_free( ssl->ticket_keys );
#endif
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
if ( ssl->hostname != NULL)
{
memset( ssl->hostname, 0, ssl->hostname_len );
polarssl_free( ssl->hostname );
ssl->hostname_len = 0;
}
#endif
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
if( ssl_hw_record_finish != NULL )