Add getter access to hostname field in mbedtls_ssl_context
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h
index 4b73b41..912ad10 100644
--- a/include/mbedtls/ssl.h
+++ b/include/mbedtls/ssl.h
@@ -3777,6 +3777,21 @@
* On too long input failure, old hostname is unchanged.
*/
int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl, const char *hostname);
+
+/**
+ * \brief Get the hostname that checked against the received
+ * server certificate. It is used to set the ServerName
+ * TLS extension, too, if that extension is enabled.
+ * (client-side only)
+ *
+ * \param ssl SSL context
+ *
+ * \return const pointer to the hostname value
+ */
+static inline const char *mbedtls_ssl_get_hostname(mbedtls_ssl_context *ssl)
+{
+ return ssl->MBEDTLS_PRIVATE(hostname);
+}
#endif /* MBEDTLS_X509_CRT_PARSE_C */
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)