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