yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
05bba0
From 00346b0ddbb4cffa91b69421353ab20f8be17f9e Mon Sep 17 00:00:00 2001
05bba0
From: Richard Jones <rjones@redhat.com>
05bba0
Date: Thu, 11 Jun 2015 11:40:22 +0200
05bba0
Subject: [PATCH 22/30] curl: Add sslverify option
05bba0
05bba0
Message-id: <1434022828-13037-16-git-send-email-rjones@redhat.com>
05bba0
Patchwork-id: 65850
05bba0
O-Subject: [RHEL-7.2 qemu-kvm v3 PATCH 15/21] curl: Add sslverify option
05bba0
Bugzilla: 1226684
05bba0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
05bba0
From: Matthew Booth <mbooth@redhat.com>
05bba0
05bba0
This allows qemu to use images over https with a self-signed certificate. It
05bba0
defaults to verifying the certificate.
05bba0
05bba0
Signed-off-by: Matthew Booth <mbooth@redhat.com>
05bba0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
05bba0
05bba0
Upstream-status: 97a3ea57198b39b8366cd2a7514707abdcd0a7bc
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 block/curl.c | 12 ++++++++++++
05bba0
 1 file changed, 12 insertions(+)
05bba0
05bba0
diff --git a/block/curl.c b/block/curl.c
05bba0
index e97682f..e48cc87 100644
05bba0
--- a/block/curl.c
05bba0
+++ b/block/curl.c
05bba0
@@ -23,6 +23,7 @@
05bba0
  */
05bba0
 #include "qemu-common.h"
05bba0
 #include "block/block_int.h"
05bba0
+#include "qapi/qmp/qbool.h"
05bba0
 #include <curl/curl.h>
05bba0
 
05bba0
 // #define DEBUG
05bba0
@@ -69,6 +70,7 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
05bba0
 
05bba0
 #define CURL_BLOCK_OPT_URL       "url"
05bba0
 #define CURL_BLOCK_OPT_READAHEAD "readahead"
05bba0
+#define CURL_BLOCK_OPT_SSLVERIFY "sslverify"
05bba0
 
05bba0
 struct BDRVCURLState;
05bba0
 
05bba0
@@ -106,6 +108,7 @@ typedef struct BDRVCURLState {
05bba0
     CURLState states[CURL_NUM_STATES];
05bba0
     char *url;
05bba0
     size_t readahead_size;
05bba0
+    bool sslverify;
05bba0
     bool accept_range;
05bba0
 } BDRVCURLState;
05bba0
 
05bba0
@@ -374,6 +377,8 @@ static CURLState *curl_init_state(BDRVCURLState *s)
05bba0
             return NULL;
05bba0
         }
05bba0
         curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
05bba0
+        curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER,
05bba0
+                         (long) s->sslverify);
05bba0
         curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5);
05bba0
         curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
05bba0
                          (void *)curl_read_cb);
05bba0
@@ -433,6 +438,11 @@ static QemuOptsList runtime_opts = {
05bba0
             .type = QEMU_OPT_SIZE,
05bba0
             .help = "Readahead size",
05bba0
         },
05bba0
+        {
05bba0
+            .name = CURL_BLOCK_OPT_SSLVERIFY,
05bba0
+            .type = QEMU_OPT_BOOL,
05bba0
+            .help = "Verify SSL certificate"
05bba0
+        },
05bba0
         { /* end of list */ }
05bba0
     },
05bba0
 };
05bba0
@@ -465,6 +475,8 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
05bba0
         goto out_noclean;
05bba0
     }
05bba0
 
05bba0
+    s->sslverify = qemu_opt_get_bool(opts, CURL_BLOCK_OPT_SSLVERIFY, true);
05bba0
+
05bba0
     file = qemu_opt_get(opts, CURL_BLOCK_OPT_URL);
05bba0
     if (file == NULL) {
05bba0
         qerror_report(ERROR_CLASS_GENERIC_ERROR, "curl block driver requires "
05bba0
-- 
05bba0
1.8.3.1
05bba0