mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge branch 'development-restricted' into merge-from-restricted
* development-restricted: Add missing credit for set_hostname issue Add changelog entry for TLS 1.2 Finished fix TLS1.2: Check for failures in Finished calculation ssl_session_reset: preserve HOSTNAME_SET flag Document the need to call mbedtls_ssl_set_hostname Improve documentation of mbedtls_ssl_set_hostname Changelog entries for requiring mbedls_ssl_set_hostname() in TLS clients Add a note about calling mbedtls_ssl_set_hostname to mbedtls_ssl_setup mbedtls_ssl_set_hostname tests: add tests with CA callback Call mbedtls_ssl_set_hostname in the generic endpoint setup in unit tests Require calling mbedtls_ssl_set_hostname() for security Create error code for mbedtls_ssl_set_hostname not called Keep track of whether mbedtls_ssl_set_hostname() has been called Access ssl->hostname through abstractions in certificate verification mbedtls_ssl_set_hostname tests: baseline Add a flags field to mbedtls_ssl_context Automate MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK dependency Make guards more consistent between X.509-has-certs and SSL-has-certs Fix Doxygen markup Make ticket_alpn field private Conflicts: programs/ssl/ssl_test_common_source.c
This commit is contained in:
@ -165,6 +165,39 @@
|
||||
#define MBEDTLS_ERR_SSL_VERSION_MISMATCH -0x5F00
|
||||
/** Invalid value in SSL config */
|
||||
#define MBEDTLS_ERR_SSL_BAD_CONFIG -0x5E80
|
||||
/* Error space gap */
|
||||
/** Attempt to verify a certificate without an expected hostname.
|
||||
* This is usually insecure.
|
||||
*
|
||||
* In TLS clients, when a client authenticates a server through its
|
||||
* certificate, the client normally checks three things:
|
||||
* - the certificate chain must be valid;
|
||||
* - the chain must start from a trusted CA;
|
||||
* - the certificate must cover the server name that is expected by the client.
|
||||
*
|
||||
* Omitting any of these checks is generally insecure, and can allow a
|
||||
* malicious server to impersonate a legitimate server.
|
||||
*
|
||||
* The third check may be safely skipped in some unusual scenarios,
|
||||
* such as networks where eavesdropping is a risk but not active attacks,
|
||||
* or a private PKI where the client equally trusts all servers that are
|
||||
* accredited by the root CA.
|
||||
*
|
||||
* You should call mbedtls_ssl_set_hostname() with the expected server name
|
||||
* before starting a TLS handshake on a client (unless the client is
|
||||
* set up to only use PSK-based authentication, which does not rely on the
|
||||
* host name). If you have determined that server name verification is not
|
||||
* required for security in your scenario, call mbedtls_ssl_set_hostname()
|
||||
* with \p NULL as the server name.
|
||||
*
|
||||
* This error is raised if all of the following conditions are met:
|
||||
*
|
||||
* - A TLS client is configured with the authentication mode
|
||||
* #MBEDTLS_SSL_VERIFY_REQUIRED (default).
|
||||
* - Certificate authentication is enabled.
|
||||
* - The client does not call mbedtls_ssl_set_hostname().
|
||||
*/
|
||||
#define MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME -0x5D80
|
||||
|
||||
/*
|
||||
* Constants from RFC 8446 for TLS 1.3 PSK modes
|
||||
@ -1222,8 +1255,8 @@ struct mbedtls_ssl_session {
|
||||
#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION && MBEDTLS_SSL_CLI_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_ALPN) && defined(MBEDTLS_SSL_SRV_C)
|
||||
char *ticket_alpn; /*!< ALPN negotiated in the session
|
||||
during which the ticket was generated. */
|
||||
char *MBEDTLS_PRIVATE(ticket_alpn); /*!< ALPN negotiated in the session
|
||||
during which the ticket was generated. */
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME) && defined(MBEDTLS_SSL_CLI_C)
|
||||
@ -1582,6 +1615,14 @@ struct mbedtls_ssl_context {
|
||||
* Miscellaneous
|
||||
*/
|
||||
int MBEDTLS_PRIVATE(state); /*!< SSL handshake: current state */
|
||||
|
||||
/** Mask of `MBEDTLS_SSL_CONTEXT_FLAG_XXX`.
|
||||
* See `mbedtls_ssl_context_flags_t` in ssl_misc.h.
|
||||
*
|
||||
* This field is not saved by mbedtls_ssl_session_save().
|
||||
*/
|
||||
uint32_t MBEDTLS_PRIVATE(flags);
|
||||
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
int MBEDTLS_PRIVATE(renego_status); /*!< Initial, in progress, pending? */
|
||||
int MBEDTLS_PRIVATE(renego_records_seen); /*!< Records since renego request, or with DTLS,
|
||||
@ -1889,6 +1930,17 @@ void mbedtls_ssl_init(mbedtls_ssl_context *ssl);
|
||||
* \note The PSA crypto subsystem must have been initialized by
|
||||
* calling psa_crypto_init() before calling this function.
|
||||
*
|
||||
* \note After setting up a client context, if certificate-based
|
||||
* authentication is enabled, you should call
|
||||
* mbedtls_ssl_set_hostname() to specifiy the expected
|
||||
* name of the server. Otherwise, if server authentication
|
||||
* is required (which is the case by default) and the
|
||||
* selected key exchange involves a certificate (i.e. is not
|
||||
* based on a pre-shared key), the certificate authentication
|
||||
* will fail. See
|
||||
* #MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
|
||||
* for more information.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param conf SSL configuration to use
|
||||
*
|
||||
@ -3738,16 +3790,29 @@ void mbedtls_ssl_conf_sig_algs(mbedtls_ssl_config *conf,
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
/**
|
||||
* \brief Set or reset the hostname to check against the received
|
||||
* server certificate. It sets the ServerName TLS extension,
|
||||
* too, if that extension is enabled. (client-side only)
|
||||
* peer certificate. On a client, this also sets the
|
||||
* ServerName TLS extension, if that extension is enabled.
|
||||
* On a TLS 1.3 client, this also sets the server name in
|
||||
* the session resumption ticket, if that feature is enabled.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param hostname the server hostname, may be NULL to clear hostname
|
||||
|
||||
* \note Maximum hostname length MBEDTLS_SSL_MAX_HOST_NAME_LEN.
|
||||
* \param hostname The server hostname. This may be \c NULL to clear
|
||||
* the hostname.
|
||||
*
|
||||
* \return 0 if successful, MBEDTLS_ERR_SSL_ALLOC_FAILED on
|
||||
* allocation failure, MBEDTLS_ERR_SSL_BAD_INPUT_DATA on
|
||||
* \note Maximum hostname length #MBEDTLS_SSL_MAX_HOST_NAME_LEN.
|
||||
*
|
||||
* \note If the hostname is \c NULL on a client, then the server
|
||||
* is not authenticated: it only needs to have a valid
|
||||
* certificate, not a certificate matching its name.
|
||||
* Therefore you should always call this function on a client,
|
||||
* unless the connection is set up to only allow
|
||||
* pre-shared keys, or in scenarios where server
|
||||
* impersonation is not a concern. See the documentation of
|
||||
* #MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
|
||||
* for more details.
|
||||
*
|
||||
* \return 0 if successful, #MBEDTLS_ERR_SSL_ALLOC_FAILED on
|
||||
* allocation failure, #MBEDTLS_ERR_SSL_BAD_INPUT_DATA on
|
||||
* too long input hostname.
|
||||
*
|
||||
* Hostname set to the one provided on success (cleared
|
||||
|
Reference in New Issue
Block a user