Blame SOURCES/0077-tcurl-test-add-support-for-tls-settings.patch

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