From 4a0d05defd8da2fb7e618e485909b9807b83acbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Mon, 27 Feb 2017 12:58:06 +0100 Subject: [PATCH 77/90] tcurl test: add support for tls settings Reviewed-by: Simo Sorce Reviewed-by: Jakub Hrozek (cherry picked from commit 886e0f75e6f4c7877a23a3625f8a20c09109b09d) --- src/tests/tcurl_test_tool.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tests/tcurl_test_tool.c b/src/tests/tcurl_test_tool.c index 7d3bc19f0ec7e118e251247536d25c58fe009f54..9cec000fbf2e4eca2fdc5213c8b3b4cb10f1df1b 100644 --- a/src/tests/tcurl_test_tool.c +++ b/src/tests/tcurl_test_tool.c @@ -37,9 +37,14 @@ struct tool_options { int debug; int verbose; int raw; + int tls; + int verify_peer; + int verify_host; enum tcurl_http_method method; const char *socket_path; + const char *capath; + const char *cacert; }; static void request_done(struct tevent_req *req) @@ -181,6 +186,14 @@ prepare_requests(TALLOC_CTX *mem_ctx, } } + if (opts->tls) { + ret = tcurl_req_verify_peer(requests[i], opts->capath, opts->cacert, + opts->verify_peer, opts->verify_host); + if (ret != EOK) { + goto done; + } + } + i++; } @@ -280,6 +293,12 @@ int main(int argc, const char *argv[]) { "del", 'd', POPT_ARG_NONE, NULL, 'd', "Perform a HTTP DELETE", NULL }, { "raw", 'r', POPT_ARG_NONE, &opts.raw, '\0', "Print raw protocol output", NULL }, { "verbose", 'v', POPT_ARG_NONE, &opts.verbose, '\0', "Print response code and body", NULL }, + /* TLS */ + { "tls", '\0', POPT_ARG_NONE, &opts.tls, '\0', "Enable TLS", NULL }, + { "verify-peer", '\0', POPT_ARG_NONE, &opts.verify_peer, '\0', "Verify peer when TLS is enabled", NULL }, + { "verify-host", '\0', POPT_ARG_NONE, &opts.verify_host, '\0', "Verify host when TLS is enabled", NULL }, + { "capath", '\0', POPT_ARG_STRING, &opts.capath, '\0', "Path to CA directory where peer certificate is stored", NULL }, + { "cacert", '\0', POPT_ARG_STRING, &opts.cacert, '\0', "Path to CA certificate", NULL }, POPT_TABLEEND }; -- 2.9.3