From 1b54c8ab931c4248339e57c538519f8b70c1babb Mon Sep 17 00:00:00 2001 From: Maximilian Fridrich Date: Tue, 30 Apr 2024 13:26:54 +0200 Subject: [PATCH] http/client: add setter to disable tls server verification (#1114) --- include/re_http.h | 1 + src/http/client.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/re_http.h b/include/re_http.h index 3e8ed965d..322eb1abf 100644 --- a/include/re_http.h +++ b/include/re_http.h @@ -173,6 +173,7 @@ int http_client_set_keypem(struct http_cli *cli, const char *pem); int http_client_set_session_reuse(struct http_cli *cli, bool enabled); int http_client_set_tls_min_version(struct http_cli *cli, int version); int http_client_set_tls_max_version(struct http_cli *cli, int version); +int http_client_disable_verify_server(struct http_cli *cli); #endif /* Server */ diff --git a/src/http/client.c b/src/http/client.c index 87ebedfb7..58a1e9302 100644 --- a/src/http/client.c +++ b/src/http/client.c @@ -1227,7 +1227,25 @@ int http_client_set_tls_max_version(struct http_cli *cli, int version) return tls_set_max_proto_version(cli->tls, version); } -#endif + + +/** + * Disable TLS server certificate verification + * + * @param cli HTTP Client + * + * @return 0 if success, otherwise errorcode + */ +int http_client_disable_verify_server(struct http_cli *cli) +{ + if (!cli) + return EINVAL; + + tls_disable_verify_server(cli->tls); + + return 0; +} +#endif /* USE_TLS */ /**