Skip to content

Commit 6086dea

Browse files
D-Trivenijukkar
authored andcommitted
Revert "[noup] zephyr: mbedtls: Fix certificate verification failure"
This reverts commit fb6452c. Revert this commit to enable hostname verification and add changes to set hostname based on domain and suffix match params for validating server certificates. Fixes #88697.
1 parent c31beae commit 6086dea

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/crypto/tls_mbedtls_alt.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,16 +2119,25 @@ struct wpabuf *tls_connection_handshake(void *tls_ctx,
21192119
mbedtls_ssl_conf_session_tickets_cb(&conn->tls_conf->conf, tls_mbedtls_ssl_ticket_write,
21202120
tls_mbedtls_ssl_ticket_parse, conn);
21212121
#endif
2122+
int ret = 0;
21222123

2123-
#ifdef MBEDTLS_X509_CRT_PARSE_C
2124-
/* This is insecure, but backwards as conf doesn't have hostname and
2125-
* for backwards compatible with MbedTLS version 3.6.3, disable
2126-
* hostname check. */
2127-
mbedtls_ssl_set_hostname(&conn->ssl, NULL);
2128-
#endif
2124+
if (conn->tls_conf->domain_match != NULL) {
2125+
ret = mbedtls_ssl_set_hostname(&conn->ssl, conn->tls_conf->domain_match);
2126+
if (ret != 0) {
2127+
wpa_printf(MSG_ERROR, "Failed to set hostname from domain match");
2128+
return NULL;
2129+
}
2130+
} else if (conn->tls_conf->suffix_match != NULL) {
2131+
ret = mbedtls_ssl_set_hostname(&conn->ssl, conn->tls_conf->suffix_match);
2132+
if (ret != 0) {
2133+
wpa_printf(MSG_ERROR, "Failed to set hostname from suffix match");
2134+
return NULL;
2135+
}
2136+
} else {
2137+
mbedtls_ssl_set_hostname(&conn->ssl, NULL);
2138+
}
21292139

21302140
#if MBEDTLS_VERSION_NUMBER >= 0x03020000 /* mbedtls 3.2.0 */
2131-
int ret = 0;
21322141
if (conn->ssl.MBEDTLS_PRIVATE(state) == MBEDTLS_SSL_HANDSHAKE_OVER &&
21332142
conn->ssl.MBEDTLS_PRIVATE(tls_version) == MBEDTLS_SSL_VERSION_TLS1_3)
21342143
{

0 commit comments

Comments
 (0)