From patchwork Wed May 14 23:28:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Booth X-Patchwork-Id: 349002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6A8FF140088 for ; Thu, 15 May 2014 09:31:10 +1000 (EST) Received: from localhost ([::1]:54920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkidg-0002kF-Aw for incoming@patchwork.ozlabs.org; Wed, 14 May 2014 19:31:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkic1-0008Ls-HF for qemu-devel@nongnu.org; Wed, 14 May 2014 19:29:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wkibs-000052-Fb for qemu-devel@nongnu.org; Wed, 14 May 2014 19:29:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkibs-00004y-70 for qemu-devel@nongnu.org; Wed, 14 May 2014 19:29:16 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4ENTFoC003339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 14 May 2014 19:29:15 -0400 Received: from t520.com (vpn1-6-174.ams2.redhat.com [10.36.6.174]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4ENT8Jl003408; Wed, 14 May 2014 19:29:13 -0400 From: Matthew Booth To: qemu-devel@nongnu.org Date: Wed, 14 May 2014 19:28:42 -0400 Message-Id: <1400110123-2692-3-git-send-email-mbooth@redhat.com> In-Reply-To: <1400110123-2692-1-git-send-email-mbooth@redhat.com> References: <1400110123-2692-1-git-send-email-mbooth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH 3/4] curl: Add sslverify option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This allows qemu to use images over https with a self-signed certificate. It defaults to verifying the certificate. Signed-off-by: Matthew Booth --- block/curl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/curl.c b/block/curl.c index 1b9f2f2..43d6646 100644 --- a/block/curl.c +++ b/block/curl.c @@ -23,6 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" +#include "qapi/qmp/qbool.h" #include // #define DEBUG @@ -69,6 +70,7 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_handle, #define CURL_BLOCK_OPT_URL "url" #define CURL_BLOCK_OPT_READAHEAD "readahead" +#define CURL_BLOCK_OPT_SSLVERIFY "sslverify" struct BDRVCURLState; @@ -106,6 +108,7 @@ typedef struct BDRVCURLState { CURLState states[CURL_NUM_STATES]; char *url; size_t readahead_size; + bool sslverify; bool accept_range; } BDRVCURLState; @@ -372,6 +375,7 @@ static CURLState *curl_init_state(BDRVCURLState *s) return NULL; } curl_easy_setopt(state->curl, CURLOPT_URL, s->url); + curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER, s->sslverify); curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5); curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_read_cb); @@ -431,6 +435,11 @@ static QemuOptsList runtime_opts = { .type = QEMU_OPT_SIZE, .help = "Readahead size", }, + { + .name = CURL_BLOCK_OPT_SSLVERIFY, + .type = QEMU_OPT_BOOL, + .help = "Verify SSL certificate" + }, { /* end of list */ } }, }; @@ -467,6 +476,8 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, goto out_noclean; } + s->sslverify = qemu_opt_get_bool(opts, CURL_BLOCK_OPT_SSLVERIFY, true); + file = qemu_opt_get(opts, CURL_BLOCK_OPT_URL); if (file == NULL) { error_setg(errp, "curl block driver requires an 'url' option");