mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-10 00:49:04 +08:00
Change some comments base on review
Change-Id: I3db2b8ca8162eb368d2f17dfeffee8b25f9edf6f Signed-off-by: XiaokangQian <xiaokang.qian@arm.com>
This commit is contained in:
parent
63e713e8ab
commit
989f06d52d
@ -551,32 +551,39 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl,
|
|||||||
static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl )
|
static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int authmode = ssl->conf->authmode;
|
int authmode = MBEDTLS_SSL_VERIFY_REQUIRED;
|
||||||
mbedtls_x509_crt *ca_chain;
|
mbedtls_x509_crt *ca_chain;
|
||||||
mbedtls_x509_crl *ca_crl;
|
mbedtls_x509_crl *ca_crl;
|
||||||
uint32_t verify_result = 0;
|
uint32_t verify_result = 0;
|
||||||
|
|
||||||
/* If SNI was used, overwrite authentication mode
|
/* If SNI was used, overwrite authentication mode
|
||||||
* from the configuration. */
|
* from the configuration. */
|
||||||
|
#if defined(MBEDTLS_SSL_SRV_C)
|
||||||
|
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER )
|
||||||
|
{
|
||||||
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
|
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
|
||||||
if( ssl->handshake->sni_authmode != MBEDTLS_SSL_VERIFY_UNSET )
|
if( ssl->handshake->sni_authmode != MBEDTLS_SSL_VERIFY_UNSET )
|
||||||
authmode = ssl->handshake->sni_authmode;
|
authmode = ssl->handshake->sni_authmode;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
authmode = ssl->conf->authmode;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the client hasn't sent a certificate ( i.e. it sent
|
* If the peer hasn't sent a certificate ( i.e. it sent
|
||||||
* an empty certificate chain ), this is reflected in the peer CRT
|
* an empty certificate chain ), this is reflected in the peer CRT
|
||||||
* structure being unset.
|
* structure being unset.
|
||||||
* Check for that and handle it depending on the
|
* Check for that and handle it depending on the
|
||||||
* server's authentication mode.
|
* authentication mode.
|
||||||
*/
|
*/
|
||||||
if( ssl->session_negotiate->peer_cert == NULL )
|
if( ssl->session_negotiate->peer_cert == NULL )
|
||||||
{
|
{
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "peer has not sent a certificate" ) );
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_SRV_C)
|
#if defined(MBEDTLS_SSL_SRV_C)
|
||||||
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER )
|
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "client has no certificate" ) );
|
|
||||||
|
|
||||||
/* The client was asked for a certificate but didn't send
|
/* The client was asked for a certificate but didn't send
|
||||||
* one. The client should know what's going on, so we
|
* one. The client should know what's going on, so we
|
||||||
* don't send an alert.
|
* don't send an alert.
|
||||||
@ -585,7 +592,11 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl )
|
|||||||
if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL )
|
if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
else
|
else
|
||||||
return( MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE );
|
{
|
||||||
|
MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_NO_CERT,
|
||||||
|
MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE );
|
||||||
|
return( MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_SSL_SRV_C */
|
#endif /* MBEDTLS_SSL_SRV_C */
|
||||||
|
|
||||||
@ -654,7 +665,6 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl )
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( ca_chain == NULL && authmode == MBEDTLS_SSL_VERIFY_REQUIRED )
|
if( ca_chain == NULL && authmode == MBEDTLS_SSL_VERIFY_REQUIRED )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no CA chain" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no CA chain" ) );
|
||||||
|
@ -1626,7 +1626,7 @@ int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl )
|
|||||||
|
|
||||||
case MBEDTLS_SSL_CLIENT_CERTIFICATE:
|
case MBEDTLS_SSL_CLIENT_CERTIFICATE:
|
||||||
ret = mbedtls_ssl_tls13_process_certificate( ssl );
|
ret = mbedtls_ssl_tls13_process_certificate( ssl );
|
||||||
if( ret == 0 && ssl->session_negotiate->peer_cert != NULL)
|
if( ret == 0 && ssl->session_negotiate->peer_cert != NULL )
|
||||||
{
|
{
|
||||||
mbedtls_ssl_handshake_set_state(
|
mbedtls_ssl_handshake_set_state(
|
||||||
ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY );
|
ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user