mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-07 06:42:56 +03:00
Keep track of whether mbedtls_ssl_set_hostname() has been called
No behavior change apart from now emitting a different log message depending on whether mbedtls_ssl_set_hostname() has been called with NULL or not at all. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@@ -51,6 +51,12 @@ extern const mbedtls_error_pair_t psa_to_ssl_errors[7];
|
||||
#define MBEDTLS_SSL_ECP_RESTARTABLE_ENABLED
|
||||
#endif
|
||||
|
||||
/** Flag values for mbedtls_ssl_context::flags. */
|
||||
typedef enum {
|
||||
/** Set if mbedtls_ssl_set_hostname() has been called. */
|
||||
MBEDTLS_SSL_CONTEXT_FLAG_HOSTNAME_SET = 1,
|
||||
} mbedtls_ssl_context_flags_t;
|
||||
|
||||
#define MBEDTLS_SSL_INITIAL_HANDSHAKE 0
|
||||
#define MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS 1 /* In progress */
|
||||
#define MBEDTLS_SSL_RENEGOTIATION_DONE 2 /* Done or aborted */
|
||||
|
@@ -2529,12 +2529,7 @@ void mbedtls_ssl_conf_groups(mbedtls_ssl_config *conf,
|
||||
static int mbedtls_ssl_has_set_hostname_been_called(
|
||||
const mbedtls_ssl_context *ssl)
|
||||
{
|
||||
/* We can't tell the difference between the case where
|
||||
* mbedtls_ssl_set_hostname() has not been called at all, and
|
||||
* the case where it was last called with NULL. For the time
|
||||
* being, we assume the latter, i.e. we behave as if there had
|
||||
* been an implicit call to mbedtls_ssl_set_hostname(ssl, NULL). */
|
||||
return ssl->hostname != NULL;
|
||||
return (ssl->flags & MBEDTLS_SSL_CONTEXT_FLAG_HOSTNAME_SET) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2580,6 +2575,8 @@ int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl, const char *hostname)
|
||||
ssl->hostname[hostname_len] = '\0';
|
||||
}
|
||||
|
||||
ssl->flags |= MBEDTLS_SSL_CONTEXT_FLAG_HOSTNAME_SET;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
Reference in New Issue
Block a user