From 436852d077087c6d4aa1ab8bad0efbe613ae2b30 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Tue, 22 Mar 2022 10:48:50 +0000 Subject: [PATCH] Enable TLS host validation in test_http_client() --- test/unit_test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/unit_test.c b/test/unit_test.c index 6c6b5a9b..369c05ea 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -825,8 +825,10 @@ static void test_http_client(void) { ok = 0; #if MG_ENABLE_MBEDTLS || MG_ENABLE_OPENSSL { - struct mg_tls_opts opts = {.ca = "./test/data/ca.pem"}; - c = mg_http_connect(&mgr, "https://cesanta.com", f3, &ok); + const char *url = "https://cesanta.com"; + struct mg_str host = mg_url_host(url); + struct mg_tls_opts opts = {.ca = "./test/data/ca.pem", .srvname = host}; + c = mg_http_connect(&mgr, url, f3, &ok); ASSERT(c != NULL); mg_tls_init(c, &opts); for (i = 0; i < 500 && ok <= 0; i++) mg_mgr_poll(&mgr, 10);