|
|
fbe740 |
From ffe8028ca07eb049b12d5c152b3d66489378d731 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <ffe8028ca07eb049b12d5c152b3d66489378d731@dist-git>
|
|
|
fbe740 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Date: Mon, 16 Mar 2020 22:11:56 +0100
|
|
|
fbe740 |
Subject: [PATCH] conf: Add support for modifying ssl validation for https/ftps
|
|
|
fbe740 |
disks
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
To allow turning off verification of SSL cerificates add a new element
|
|
|
fbe740 |
<ssl> to the disk source XML which will allow configuring the validation
|
|
|
fbe740 |
process using the 'verify' attribute.
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
(cherry picked from commit 25481e25b14108373bf2e5e95c04fe30bff96bb4)
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
|
|
|
fbe740 |
Message-Id: <ede13179128fc9ef05036a5408f4115132a2c12d.1584391727.git.pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
docs/formatdomain.html.in | 9 ++++
|
|
|
fbe740 |
docs/schemas/domaincommon.rng | 51 ++++++++++++++++++-
|
|
|
fbe740 |
src/conf/domain_conf.c | 19 +++++++
|
|
|
fbe740 |
src/util/virstoragefile.c | 1 +
|
|
|
fbe740 |
src/util/virstoragefile.h | 1 +
|
|
|
fbe740 |
.../disk-network-http.xml | 9 ++++
|
|
|
fbe740 |
6 files changed, 88 insertions(+), 2 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
|
|
|
fbe740 |
index e9830ab231..2cce247958 100644
|
|
|
fbe740 |
--- a/docs/formatdomain.html.in
|
|
|
fbe740 |
+++ b/docs/formatdomain.html.in
|
|
|
fbe740 |
@@ -2847,6 +2847,7 @@
|
|
|
fbe740 |
<driver name='qemu' type='raw'/>
|
|
|
fbe740 |
<source protocol="https" name="url_path">
|
|
|
fbe740 |
<host name="hostname" port="443"/>
|
|
|
fbe740 |
+ <ssl verify="no"/>
|
|
|
fbe740 |
</source>
|
|
|
fbe740 |
<target dev='hdf' bus='ide' tray='open'/>
|
|
|
fbe740 |
<readonly/>
|
|
|
fbe740 |
@@ -3373,6 +3374,14 @@
|
|
|
fbe740 |
The offset and size values are in bytes.
|
|
|
fbe740 |
Since 6.1.0
|
|
|
fbe740 |
|
|
|
fbe740 |
+ ssl
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ For https and ftps accessed storage it's
|
|
|
fbe740 |
+ possible to tweak the SSL transport parameters with this element.
|
|
|
fbe740 |
+ The verify attribute allows to turn on or off SSL
|
|
|
fbe740 |
+ certificate validation. Supported values are yes and
|
|
|
fbe740 |
+ no . Since 6.2.0
|
|
|
fbe740 |
+
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
|
|
|
fbe740 |
index aa70e340b9..548601b61c 100644
|
|
|
fbe740 |
--- a/docs/schemas/domaincommon.rng
|
|
|
fbe740 |
+++ b/docs/schemas/domaincommon.rng
|
|
|
fbe740 |
@@ -1808,12 +1808,39 @@
|
|
|
fbe740 |
</element>
|
|
|
fbe740 |
</define>
|
|
|
fbe740 |
|
|
|
fbe740 |
+ <define name="diskSourceNetworkProtocolSSLVerify">
|
|
|
fbe740 |
+ <element name="ssl">
|
|
|
fbe740 |
+ <attribute name="verify">
|
|
|
fbe740 |
+ <ref name="virYesNo"/>
|
|
|
fbe740 |
+ </attribute>
|
|
|
fbe740 |
+ <empty/>
|
|
|
fbe740 |
+ </element>
|
|
|
fbe740 |
+ </define>
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ <define name="diskSourceNetworkProtocolHTTPS">
|
|
|
fbe740 |
+ <element name="source">
|
|
|
fbe740 |
+ <attribute name="protocol">
|
|
|
fbe740 |
+ <choice>
|
|
|
fbe740 |
+ <value>https</value>
|
|
|
fbe740 |
+ </choice>
|
|
|
fbe740 |
+ </attribute>
|
|
|
fbe740 |
+ <attribute name="name"/>
|
|
|
fbe740 |
+ <ref name="diskSourceCommon"/>
|
|
|
fbe740 |
+ <ref name="diskSourceNetworkHost"/>
|
|
|
fbe740 |
+ <optional>
|
|
|
fbe740 |
+ <ref name="encryption"/>
|
|
|
fbe740 |
+ </optional>
|
|
|
fbe740 |
+ <optional>
|
|
|
fbe740 |
+ <ref name="diskSourceNetworkProtocolSSLVerify"/>
|
|
|
fbe740 |
+ </optional>
|
|
|
fbe740 |
+ </element>
|
|
|
fbe740 |
+ </define>
|
|
|
fbe740 |
+
|
|
|
fbe740 |
<define name="diskSourceNetworkProtocolHTTP">
|
|
|
fbe740 |
<element name="source">
|
|
|
fbe740 |
<attribute name="protocol">
|
|
|
fbe740 |
<choice>
|
|
|
fbe740 |
<value>http</value>
|
|
|
fbe740 |
- <value>https</value>
|
|
|
fbe740 |
</choice>
|
|
|
fbe740 |
</attribute>
|
|
|
fbe740 |
<attribute name="name"/>
|
|
|
fbe740 |
@@ -1825,13 +1852,31 @@
|
|
|
fbe740 |
</element>
|
|
|
fbe740 |
</define>
|
|
|
fbe740 |
|
|
|
fbe740 |
+ <define name="diskSourceNetworkProtocolFTPS">
|
|
|
fbe740 |
+ <element name="source">
|
|
|
fbe740 |
+ <attribute name="protocol">
|
|
|
fbe740 |
+ <choice>
|
|
|
fbe740 |
+ <value>ftps</value>
|
|
|
fbe740 |
+ </choice>
|
|
|
fbe740 |
+ </attribute>
|
|
|
fbe740 |
+ <attribute name="name"/>
|
|
|
fbe740 |
+ <ref name="diskSourceCommon"/>
|
|
|
fbe740 |
+ <ref name="diskSourceNetworkHost"/>
|
|
|
fbe740 |
+ <optional>
|
|
|
fbe740 |
+ <ref name="encryption"/>
|
|
|
fbe740 |
+ </optional>
|
|
|
fbe740 |
+ <optional>
|
|
|
fbe740 |
+ <ref name="diskSourceNetworkProtocolSSLVerify"/>
|
|
|
fbe740 |
+ </optional>
|
|
|
fbe740 |
+ </element>
|
|
|
fbe740 |
+ </define>
|
|
|
fbe740 |
+
|
|
|
fbe740 |
<define name="diskSourceNetworkProtocolSimple">
|
|
|
fbe740 |
<element name="source">
|
|
|
fbe740 |
<attribute name="protocol">
|
|
|
fbe740 |
<choice>
|
|
|
fbe740 |
<value>sheepdog</value>
|
|
|
fbe740 |
<value>ftp</value>
|
|
|
fbe740 |
- <value>ftps</value>
|
|
|
fbe740 |
<value>tftp</value>
|
|
|
fbe740 |
</choice>
|
|
|
fbe740 |
</attribute>
|
|
|
fbe740 |
@@ -1909,6 +1954,8 @@
|
|
|
fbe740 |
<ref name="diskSourceNetworkProtocolRBD"/>
|
|
|
fbe740 |
<ref name="diskSourceNetworkProtocolISCSI"/>
|
|
|
fbe740 |
<ref name="diskSourceNetworkProtocolHTTP"/>
|
|
|
fbe740 |
+ <ref name="diskSourceNetworkProtocolHTTPS"/>
|
|
|
fbe740 |
+ <ref name="diskSourceNetworkProtocolFTPS"/>
|
|
|
fbe740 |
<ref name="diskSourceNetworkProtocolSimple"/>
|
|
|
fbe740 |
<ref name="diskSourceNetworkProtocolVxHS"/>
|
|
|
fbe740 |
</choice>
|
|
|
fbe740 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
fbe740 |
index b3c4084c38..70bbc35bb3 100644
|
|
|
fbe740 |
--- a/src/conf/domain_conf.c
|
|
|
fbe740 |
+++ b/src/conf/domain_conf.c
|
|
|
fbe740 |
@@ -9259,6 +9259,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
|
|
|
fbe740 |
g_autofree char *protocol = NULL;
|
|
|
fbe740 |
g_autofree char *haveTLS = NULL;
|
|
|
fbe740 |
g_autofree char *tlsCfg = NULL;
|
|
|
fbe740 |
+ g_autofree char *sslverifystr = NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(protocol = virXMLPropString(node, "protocol"))) {
|
|
|
fbe740 |
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
fbe740 |
@@ -9331,6 +9332,19 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
|
|
|
fbe740 |
|
|
|
fbe740 |
virStorageSourceInitiatorParseXML(ctxt, &src->initiator);
|
|
|
fbe740 |
|
|
|
fbe740 |
+ if ((src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS ||
|
|
|
fbe740 |
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_FTPS) &&
|
|
|
fbe740 |
+ (sslverifystr = virXPathString("string(./ssl/@verify)", ctxt))) {
|
|
|
fbe740 |
+ int verify;
|
|
|
fbe740 |
+ if ((verify = virTristateBoolTypeFromString(sslverifystr)) < 0) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
fbe740 |
+ _("invalid ssl verify mode '%s'"), sslverifystr);
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ src->sslverify = verify;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -24312,6 +24326,11 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
|
|
|
fbe740 |
|
|
|
fbe740 |
virStorageSourceInitiatorFormatXML(&src->initiator, childBuf);
|
|
|
fbe740 |
|
|
|
fbe740 |
+ if (src->sslverify != VIR_TRISTATE_BOOL_ABSENT) {
|
|
|
fbe740 |
+ virBufferAsprintf(childBuf, "<ssl verify='%s'/>\n",
|
|
|
fbe740 |
+ virTristateBoolTypeToString(src->sslverify));
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
|
|
fbe740 |
index b88763b267..cfa77fccf8 100644
|
|
|
fbe740 |
--- a/src/util/virstoragefile.c
|
|
|
fbe740 |
+++ b/src/util/virstoragefile.c
|
|
|
fbe740 |
@@ -2270,6 +2270,7 @@ virStorageSourceCopy(const virStorageSource *src,
|
|
|
fbe740 |
def->cachemode = src->cachemode;
|
|
|
fbe740 |
def->discard = src->discard;
|
|
|
fbe740 |
def->detect_zeroes = src->detect_zeroes;
|
|
|
fbe740 |
+ def->sslverify = src->sslverify;
|
|
|
fbe740 |
|
|
|
fbe740 |
/* storage driver metadata are not copied */
|
|
|
fbe740 |
def->drv = NULL;
|
|
|
fbe740 |
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
|
|
|
fbe740 |
index 5b995d54ab..fab4248c3d 100644
|
|
|
fbe740 |
--- a/src/util/virstoragefile.h
|
|
|
fbe740 |
+++ b/src/util/virstoragefile.h
|
|
|
fbe740 |
@@ -282,6 +282,7 @@ struct _virStorageSource {
|
|
|
fbe740 |
virStorageEncryptionPtr encryption;
|
|
|
fbe740 |
bool encryptionInherited;
|
|
|
fbe740 |
virStoragePRDefPtr pr;
|
|
|
fbe740 |
+ virTristateBool sslverify;
|
|
|
fbe740 |
|
|
|
fbe740 |
virStorageSourceNVMeDefPtr nvme; /* type == VIR_STORAGE_TYPE_NVME */
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/tests/genericxml2xmlindata/disk-network-http.xml b/tests/genericxml2xmlindata/disk-network-http.xml
|
|
|
fbe740 |
index fde1222fd0..bdcc1977f2 100644
|
|
|
fbe740 |
--- a/tests/genericxml2xmlindata/disk-network-http.xml
|
|
|
fbe740 |
+++ b/tests/genericxml2xmlindata/disk-network-http.xml
|
|
|
fbe740 |
@@ -25,6 +25,7 @@
|
|
|
fbe740 |
<driver name='qemu' type='raw'/>
|
|
|
fbe740 |
<source protocol='https' name='test2.img'>
|
|
|
fbe740 |
<host name='example.org' port='443'/>
|
|
|
fbe740 |
+ <ssl verify='no'/>
|
|
|
fbe740 |
</source>
|
|
|
fbe740 |
<target dev='vdb' bus='virtio'/>
|
|
|
fbe740 |
</disk>
|
|
|
fbe740 |
@@ -35,6 +36,14 @@
|
|
|
fbe740 |
</source>
|
|
|
fbe740 |
<target dev='vdc' bus='virtio'/>
|
|
|
fbe740 |
</disk>
|
|
|
fbe740 |
+ <disk type='network' device='disk'>
|
|
|
fbe740 |
+ <driver name='qemu' type='raw'/>
|
|
|
fbe740 |
+ <source protocol='https' name='test4.img'>
|
|
|
fbe740 |
+ <host name='example.org' port='1234'/>
|
|
|
fbe740 |
+ <ssl verify='yes'/>
|
|
|
fbe740 |
+ </source>
|
|
|
fbe740 |
+ <target dev='vdd' bus='virtio'/>
|
|
|
fbe740 |
+ </disk>
|
|
|
fbe740 |
<controller type='usb' index='0'/>
|
|
|
fbe740 |
<controller type='pci' index='0' model='pci-root'/>
|
|
|
fbe740 |
<input type='mouse' bus='ps2'/>
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.25.1
|
|
|
fbe740 |
|