From f8f031405c056a5d6cda4583989c8db7a8ae6375 Mon Sep 17 00:00:00 2001 From: Maximilian Fridrich Date: Mon, 29 Apr 2024 07:30:37 +0200 Subject: [PATCH] http/client: add setter to disable tls server verification --- 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..3b71efc30 100644 --- a/include/re_http.h +++ b/include/re_http.h @@ -156,6 +156,7 @@ void http_client_set_laddr(struct http_cli *cli, const struct sa *addr); void http_client_set_laddr6(struct http_cli *cli, const struct sa *addr); void http_client_set_bufsize_max(struct http_cli *cli, size_t max_size); size_t http_client_get_bufsize_max(struct http_cli *cli); +int http_client_disable_verify_server(struct http_cli *cli); #ifdef USE_TLS int http_client_set_tls(struct http_cli *cli, struct tls *tls); 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 */ /**